1忌卤、查找/var目錄下不屬于root、lp楞泼、gdm的所有文件
find /var! \( -user root -o -user lp -o -user gdm \)
2驰徊、統(tǒng)計/etc/init.d/functions文件中每個單詞的出現(xiàn)次數(shù)笤闯, 并排序(用grep和sed兩種方法分別實現(xiàn))
grep -o' [[:alpha:]]\+ '/etc/init.d/functions| sort | uniq -csed -r's@[^[:alpha:]]+@\n@g'/etc/init.d/functions| sort | uniq -c| sort -n
3、利用sed 取出ifconfig命令中本機的IPv4地址
ifconfig | sed -n'/inet .* netmask/p'| sed -n -r's/inet (.*) netmask.*$/\1/p'| head -1
4棍厂、總結(jié)yum的配置和使用颗味,包括yum倉庫的創(chuàng)建
配置自己的yum倉庫來實現(xiàn)yum安裝在/etc/yum.repo/目錄中新建一個以.repo后綴中的文件指定本機yum安裝路徑通常分四種
http:// https:// ftp:// file:// 前三中為網(wǎng)絡(luò)路徑 file為本地路徑
一、掛載光盤到目錄
lsblk
mkdir /data/base
mount /der/sr0 /data/base/
二勋桶、創(chuàng)建修改 /etc/yum.repos.d/base.repo文件
配置本地的yum路徑將本地路徑指向本地yum源就可以使用了
[base]name=cdrom repo 軟件倉庫指定名字baseurl=file://data/base 指定路徑指向本地掛載光盤gogcheck=0包校驗0為不校驗1為校驗
也可配置將路徑指向網(wǎng)絡(luò)中的yum倉庫
[base]name=cdrom repo 軟件倉庫指定名字baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ 指定路徑指向網(wǎng)絡(luò)中的yum倉庫gogcheck=0包校驗0為不校驗1為校驗
5脱衙、編寫系統(tǒng)初始化腳本reset.sh,包括別名例驹,提示符顏色捐韩,yum倉庫配置文件
#!/bin/bash##********************************************************************#Author: DreamDZhu#QQ: 852749070#Date: 2019-01-30#FileName: autoInitSystem.sh#Description: AutoInitSystem#********************************************************************#decide current system osecho "Start Init System,Please Waiting Some Time~~"sleep 2
version=`egrep -o "[0-9]" /etc/redhat-release |head -n1`echo "Current System Version is Centos$version"echo "Setting Alias...."sleep 1
cat >>/root/.bashrc<<ENDalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'alias cdnet='cd /etc/sysconfig/network-scripts/'alias IPOUT='ifconfig | egrep -o "\<([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}\>" | head -1'alias p='poweroff'alias cl='clear'`if [ "$version" -eq 7 ];then? ? ps1="\[\e[1;36m\][\u@\h \W]\$\[\e[0m\]"elif [ "$version" -eq 6 ];then? ? ps1="\[\e[1;33m\][\u@\h \W]\$\[\e[0m\]"else? ? ps1="\[\e[1;35m\][\u@\h \W]\$\[\e[0m\]"fi`
PS1=$ps1ENDecho "Alias and PS1 be Ready~"echo "Start Setting Yum Repository..."sleep 1#mount cd rommkdir /media/cdrom
mount /dev/sr0 /media/cdrom
mkdir /etc/yum.repos.d/bak#move system Centos repomv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
cat >>/etc/yum.repos.d/bash.repo<<END
[base]
name=Centos "$version"baseurl=file:///media/cdrom
gpgcheck=0
[epel]
name=Aliyun
baseurl=https://mirrors.aliyun.com/epel/$version/x86_64
gpgcheck=1
gpgkey=file:///media/cdrom/RPM-GPG-KEY-CentOS-$versionENDecho "Yum Repo be Ready~"echo "Start Install Rpms"sleep 1
yum cleanall && yum makecache
yum -y install tree && yum -y install ftp && yum -y install lftp && yum -y install telnetecho "tree ,ftp,lftp,telnet already Install~"if [ $version -eq 7 ];then? ? systemctl stop firewalld
? ? systemctl disable firewalldelif [ $version -eq 6 ];then? ? service iptables stop
? ? chkconfig iptables offelse? ? echo "Please Manual Stop Firewall"echo "Init System Over"
6、安裝tree鹃锈,ftp荤胁,lftp,telnet等包
yum install tree ftp lftp telnet
7屎债,centos7上編譯安裝apache2.4源碼包并啟動此程序
一仅政、準(zhǔn)備工作
在進行編譯安裝前均需要安裝相關(guān)的依賴軟件包,如:
yum install -y gcc gcc++ zlib zlib-devel expat-devel pcre-devel
隨后使用wget命令下載相應(yīng)的源碼包到指定的目錄:
httpd:http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
apr:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
apr-util:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
在做完相應(yīng)的準(zhǔn)備工作后盆驹,可以開始編譯安裝的過程了圆丹。
二、編譯安裝
在編譯安裝httpd的源碼包之前躯喇,我們得下編譯安裝apr和apr-until這兩個對應(yīng)源碼包辫封。
1、安裝apr
[root@localhost tmp]# tar xf apr-1.6.3.tar.gz? ? [root@localhost tmp]# cd apr-1.6.3[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.6.3]# make && make install
2廉丽、安裝apr-util
[root@localhost tmp]# tar xf apr-util-1.6.1.tar.gz [root@localhost tmp]# cd apr-util-1.6.1[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[root@localhost apr-util-1.6.1]# make && make install
3倦微、安裝httpd
[root@localhost tmp]# tar xf httpd-2.4.29.tar.gz [root@localhost tmp]# cd httpd-2.4.29[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util[root@localhost httpd-2.4.29]# make && make install
三、編譯安裝完成后的工作
1正压、啟動Apache
[root@localhost ~]# cd /usr/local/apache/bin/[root@localhost bin]# ./apachectl start
需要編輯/usr/local/apache/conf/httpd.conf文件中找到#ServerName www.example.com:80并在其下方添加:ServerName localhost:80欣福。
2、修改iptables允許訪問80端口
通過情況下焦履,Linux系統(tǒng)的iptables 會拒絕任何訪問到80端口的流量拓劝,此時可以通過使用iptables添加對應(yīng)的訪問規(guī)則來允許對應(yīng)的流量。
[root@localhost ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT[root@localhost ~]# service iptables saveiptables:Saving firewall rules to /etc/sysconfig/iptables:[? 確定? ]
如果系統(tǒng)無法找到service iptables save命令嘉裤,需先yum安裝iptables-service凿将。
另外也可以停用iptables:
[root@localhost ~]# systemctl stop firewalld? ? ? #臨時停用firewalld[root@localhost ~]# systemctl disable firewalld? #關(guān)閉開機自動開啟firewalldRemoved symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
3、設(shè)置開機自動開啟apache
首先將/usr/local/apache/bin/apachectl 復(fù)制到/etc/init.d/目錄下价脾。
[root@localhost ~]# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/
隨后編輯/etc/rc.d/init.d/apachectl,在首行#!/bin/sh下添加下面兩句命令:
#chkconfig: 234 20 80#escription: apache
隨后用chkconfig命令將apachectl添加到系統(tǒng)服務(wù)并設(shè)置開機啟動:
[root@localhost ~]# chkconfig --add apachectlroot@localhost ~]# chkconfig apachectl on
此時使用systemctl命令就能正常管理到apachectl服務(wù)了:
[root@localhost ~]# systemctl status apachectl● apachectl.service -SYSV:apacheLoaded:loaded (/etc/rc.d/init.d/apachectl)Active:active (exited) since 五2018-01-0505:14:59CST;5s agoDocs:man:systemd-sysv-generator(8)Process:66466ExecStart=/etc/rc.d/init.d/apachectl start (code=exited, status=0/SUCCESS)1月0505:14:59localhost.localdomain systemd[1]: StartingSYSV:apache...1月0505:14:59localhost.localdomain apachectl[66466]: httpd (pid64222) already running1月0505:14:59localhost.localdomain systemd[1]: StartedSYSV:apache.[root@localhost ~]#