第四周做業

1.查找/var目錄下不屬於root、lp、gdm的全部文件。
find /var -not \ (-user root -o -user lp -user gdm) -ls

python

2.統計/etc/init.d/functions文件中的每一個單詞出現次數,並排序,用grep和sed兩種方法實現。apache

sed方法實現:
sed -r 's@[^[:alpha:]]+@\n@g' /etc/init.d/functions | sort | uniq -c | sort -n

緩存

grep方法實現:
egrep -o "\<[[:alpha:]]+\>" /etc/init.d/functions | sort | uniq -c | sort -nbash

 

三、利用sed命令取出ifconfig命令中的IPv4地址。
ifconfig | sed -n '2p' | sed  's/^[[:space:]].*r://' | sed 's/[[:space:]].*//'服務器

 

4.總結yum的配置和使用,包括yum的庫的建立。
yum配置:
yum的配置文件分爲兩部分:main和repositoy
  man部分定義了全局配置選項,整個yum配置文件應該只有一個main,位於 /etc/yum.conf 中;
  repository 部分定義了每一個源/服務器的具體配置,能夠有一到多個。位於 /etc/yum.repo.d 目錄下的各個文件中app

yum命令: url

yum install 包名    安裝包
yum remove 包名   卸載包
yum clean       清除yum緩存
yum makecache    構建緩存
yum repolist      顯示倉庫列表
yum list        顯示程序包
yum info [...]      查看程序包信息spa

 

建立本地yum倉庫(ISO):
首先掛載CentOS 7光盤ISO
將Packages和repodata複製到/data/yum/下
安裝deltarpm、python-deltarpm、createrepo
在Packages目錄使用createrepo生成yum倉庫依賴關係
編輯yum倉庫配置文件,進入配置文件目錄(先備份!)排序

 

5.編寫系統初始化腳本reset.sh,包括別名,提示符顏色,yum倉庫配置文件。ssl

 

#!/bin/bash
alias disepel="sed -i 's/enabled=.*/enabled=0/' /etc/yum.repos.d/cdrom.repo"
alias enaepel="sed -i 's/enabled=.*/enabled=1/' /etc/yum.repos.d/cdrom.repo"
PS1='\[\e[31m\][\u\]\e[0m\]\[\e[1;33m\]@\[\e[0m\]\e[36m\]\W\t\]]\e[0m\]'

mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
touch /etc/yum.repos.d/cdrom.repo
cat >>/ect/yum.repos.d/cdrom.repo<<EOF
[cdrom]
name=cdrom
baseurl=file:///mnt/cdrom
gpgcheck=1
EOF

 

 

6.安裝tree,ftp,telent,lftp等包。

yum install -y tree ftp telent lftp

 

7.在CentOS7上編譯安裝apache2.4源碼包,啓動此服務。

a.yum groupinstall 「development tools」
yum install apr-devel apr-util-devel pcre-devel openssl-devel

b.useradd -r -u 80 -d /data/www/ -s /sbin/nologin httpd

c.tar xf httpd-2.4.25.tar.bz2
cd httpd-2.4.25/

d.cat readme
cat install

e…/configure --help
./configure --prefix=/app/httpd --sysconfdir=/etc/httpd24 --enable-ssl --disable-status

f.make && make install

g.PATH變量
echo 'PATH=/app/httpd/bin:$PATH > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh

h.apachectl start

相關文章
相關標籤/搜索