1. 查找/var目录下不属于root、lp、gdm的所有文件
- find /var -not ( -user root -o -user gdm -o -user lp ) -ls
2. 统计/etc/init.d/functions文件中每个单词的出现次数,并排序(用grep和sed两种方法分别实现)
- grep -Eo "[a-zA-Z]+" /etc/init.d/functions |sort|uniq -c|sort -nr
- sed -nr "s/[^[:alpha:]]+/\n/pg" /etc/init.d/functions|sort|uniq -c|sort -nr
3. 利用sed取出ifconfig命令中本机的IPv4地址
ifconfig eth0|sed -nr "s/.inet (addr:)?([^ ]+)./\1/p"
4. 总结yum的配置和使用,包括yum仓库的创建
- yum的配置
/etc/yum.conf yum的全局配置文件
/etc/yum.repos.d/*.repo yum仓库的配置文件都存放在这里 - yum的使用
- yum install 安装包
- yum reinstall 重新安装包
- yum remove 移除包
- yum update 升级包
- yum downgrade 降级包
- yum check-update 检查可用升级
- yum info 查看包的信息
- yum provides 后面跟文件,可以查看此文件是哪个包提供的
- yum repolist 显示仓库列表
-yum list 显示包列表 - yum search 搜索包
-yum deplist 查看指定的包所依赖的包 - yum history 查看yum事物历史
yum history [info|list|packages-list|packages-info| summary|addon-info|redo|undo|rollback|new|sync|stats]
yum history redo 重做 yum history rollback 回滚 undo 撤销 - yum clean all 清除本地缓存,路径在/var/cache/yum/releasever里的文件
- yum group install 安装包组
- yum group remove 移除包组
- yum group list 显示包组
- yum group info 显示包组信息
- yum 仓库的创建
- 在/etc/yum.repos.d/目录下创建后缀为.repo的文件
- [] 里面添加仓库的名字
- name= 可有可无,仓库的说明内容
- baseurl=仓库的路径
- gpgcheck= 1表示需要检查包的完整性,后面需要添加gpgkey=的路径,0代表不检查
- 仓库支持的变量:basearch=系统的平台:x86_64
5. 编写系统初始化脚本reset.sh ,包括别名,提示符,yum仓库
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#别名
echo 'alias vi='vim'' >> ~/.bashrc
echo 'alias yy='yum -y'' >> ~/.bashrc
echo 'alias scandisk='echo - - - > /sys/class/scsi_host/host2/scan'' >> ~/.bashrc
#提示符颜色
echo 'PS1="\[\e[1;41;33m\][\u@\h \W]\\$\[\e[0m\]"' >> /etc/profile.d/env.sh
#yum仓库
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
cat >> /etc/yum.repos.d/base.repo <<\EOF
[development]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[epel]
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
EOF
6. 安装tree,ftp,lftp,telnet等包
yum install tree ftp lftp telnet
7. 在centos7上编译安装apache2.4源码包,并启动服务
- wget https://www.apache.org/dist/httpd/httpd-2.4.39.tar.bz2
- tar xvf httpd-2.4.39.tar.bz2
- cd httpd-2.4.39
- ./configure --prefix=/usr/local/apache
- make && make install
- /usr/local/apache/bin/httpd -k start