命令用法习题,yum仓库的创建 chapter02

1、  分别用cat ac l三个命令查看文件/etc/ssh/sshd_config文件中的内容,并用自己的话总计出这三个文档操作命令的不同之处?

[root@localhost /]# cat /etc/ssh/sshd_config

[root@localhost /]# tac /etc/ssh/sshd_config

[root@localhost /]# nl /etc/ssh/sshd_config

cat正序显示文件内容

tac倒序显示文件内容

nl显示文件内容的时候不显示行号

 

2、  分别用more和less查看/etc/ssh/sshd_config里面的内容,请用总结more和less两个命令的相同和不同之处?

more /etc/ssh/sshd_config

less /etc/ssh/sshd_config

相同:都是分页显示文件内容

不同:less的扩展功能更多 , 在less显示的文件内容中,可按“/”查找内容“n”下一个,“N”上一个

3、将/etc/passwd文件中的前20行重定向保存到/root下改名为20_pass.txt,将/etc/passwd文件中的后15行重定向保存到/root下改名为:pass_15.txt

[root@localhost /]# head -20 /etc/passwd > /root/20_pass.txt

[root@localhost /]# tail -15 /etc/passwd > /root/pass_15.txt

 

4、请用一个命令统计/etc/hosts文件包含有多少行?多少字节?多少单词数?

[root@localhost /]# wc -l /etc/hosts

2 /etc/hosts

[root@localhost /]# wc -c /etc/hosts

158 /etc/hosts

[root@localhost /]# wc -w /etc/hosts

10 /etc/hosts

5、练习使用grep和egrep

5.1.通过grep管道工具过滤出ifconfig命令显示信息中的IP字段?

 [root@localhost ~]# ifconfig | grep "inet"

5.2.将/etc/passwd文件中的前20行重定向保存到/root下名称为pass?

[root@localhost /]# head -20 /etc/passwd > /root/pass

5.3.过滤/etc/passwd文件中含有/sbin/nologin 的行并统计行数?

[root@localhost /]# grep "/sbin/nologin" /etc/passwd | wc -l

 

5.4 过滤/etc/passwd文件中以sh结尾的行,及以 root开头的行,不显示包含login的行?

[root@localhost /]# grep "sh$" /etc/passwd | grep "^root" | grep -v "login"

5.5 分别用grep和egrep过滤出/etc/ssh/sshd_config文件中不包含“#”开头和空白的行?

 

[root@localhost /]# grep -v "^#" /etc/ssh/sshd_config | grep -v "^$"

[root@localhost /]# egrep -v "^#|^$" /etc/ssh/sshd_config

 

6.1 通过tar命令将/etc/passwd文件打包压缩成/root/file.tar.gz

[root@localhost /]# tar zcvf /root/file.tar.gz etc/passwd

etc/passwd

6.2通过tar命令将/etc/passwd文件打包压缩成/root/file.tar.bz2

 

[root@localhost /]# tar jcvf /root/file.tar.bz2 /etc/passwd

6.3创建空文件夹/web/test1,并将file.tar.bz2 解包并释放到/web/test1目录下?

[root@localhost /]# mkdir -pv /web/test1

[root@localhost /]# tar xf /root/file.tar.bz2 -C /web/test1

 

7.1 通过vi编辑/web/test1/passwd文件将文件里为root单词全部替换成benet。

:% s/root/benet/g

7.2 通过vi编辑 删除pass文件第1、5、10行。

1G dd    5G dd  10G dd

7.3 在vi中显示pass文件行号复制文件2 3 4行粘贴到以lp开头的行下。

2G 3yy  /lp enter  p

7.4 通过vi编辑 查找文件内包含mail var等字符串,并记录所在行号。

:set nu /mail enter    9   /var enter  

7.5 通过vi编辑 快速跳转到文件的第二行,通过r 读取 /etc/hosts 文件的内容到第二行下。

2G    :r /etc/hosts

7.6将更改后的文件使用vim另存为/root/new_pass。

:w /root/new_pass

7.7将new_pass文件压缩成gz格式并改名为npass.gz文件。

gzip new_pass.tar.gz > npass.gz 

8统计/dev 目录下的文件数量。

ls -l /dev | wc -l

9.1在/boot下查找文件名以vmlinuz开头的文件?

find /boot -name “vmlinuz*”

9.2在/boot下查找文件大小大于3M 小于 20M 的文件

find /boot -size +3M -a -size -20M

10 请详细写出构建本地yum仓库的步骤?并在每行命令后面用自己的话做上中文注释?

卸载光盘 umount /dev/sr0

挂载光盘 mount /fev/sr0 /media/

ls /media/

 

构建本地yum仓库文档

cd /etc/yum.r*

mkdir a/

mv C* a/

 

创建本地yum仓库

vi local.repo

[cdrom]  仓库名称

name=cdrom

baseurl=file:///media  指定rpm包的指定位置

enabled=1  启动本地yum仓库

gpgcheck=0  禁用gpg校验

 

yum -y clean all 清除yum缓存

yum makecache 重建yum缓存

 

查看是否安装vsftpd

rpm -q vsftpd

用yum 安装vsftpd

yum -y install vsftpd

查看是否安装 vsftpd

rpm -q vsftpd

用yum卸载 vsftpd

yum -y remove vsftpd

查看是否安装 vsftpd

rpm -q vsftpd

 

11、用yum命令安装vsftpd,查询安装情况,最后卸载vsftpd,并再次查询卸载情况?

yum -y install vsftpd

查看是否安装 vsftpd

rpm -q vsftpd

用yum卸载 vsftpd

yum -y remove vsftpd

查看是否安装 vsftpd

rpm -q vsftpd

 

12、用rpm命令安装vsftpd,查询安装情况,最后卸载vsftpd,并再次查询卸载情况?

rpm -q vsftpd

用yum卸载 vsftpd

yum -y remove vsftpd

查看是否安装 vsftpd

rpm -q vsftpd

13、通过源码方式通过解包、配置、编译、安装四个步骤安装源码软件httpd-2.2.17.tar.gz?并进行测试?

原文地址:https://www.cnblogs.com/canflyfish/p/11252685.html