chapter02 - 03

mac2022-06-30  21

chapter02 - 03  1、 分别用cat \tac\nl三个命令查看文件/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      显示行号并查看内容 2、分别用more和less查看/etc/ssh/sshd_config里面的内容,请用总结more和less两个命令的相同和不同之处? [root@localhost ~]# more /etc/ssh/sshd_config     查看内容只能往下看 [root@localhost ~]# less /etc/ssh/sshd_config       查看内容上下都能看,”/”可以查想查内容 3、将/etc/passwd文件中的前20行重定向保存到/root下改名为20_pass.txt,将/etc/passwd文件中的后15行重定向保存到/root下改名为:pass_15.txt [root@localhost ~]# head  -20 /etc/passwd >20_pass.txt [root@localhost ~]# tail -15 /etc/passwd >pass_15.txt 4、请用一个命令统计/etc/hosts文件包含有多少行?多少字节?多少单词数? [root@localhost ~]# wc -l /etc/hosts 2 /etc/hosts [root@localhost ~]# wc -w /etc/hosts 10 /etc/hosts [root@localhost ~]# wc -c /etc/hosts 158 /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 >pass 5.3.过滤/etc/passwd文件中含有/sbin/nologin 的行并统计行数? [root@localhost ~]# egrep -v "/sbin/nolgin" /etc/passwd | cat -n 5.4 过滤/etc/passwd文件中以sh结尾的行,及以 root开头的行,不显示包含login的行? [root@localhost ~]# grep "^root" /etc/passwd |grep "sh$"|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 -cvzf file.tar.gz /etc/passwd 6.2通过tar命令将/etc/passwd文件打包压缩成/root/file.tar.bz2 [root@localhost ~]# tar -cvjf file.tar.bz2 /etc/passwd 6.3创建空文件夹/web/test1,并将file.tar.bz2 解包并释放到/web/test1目录下? [root@localhost ~]# tar -xf file.tar.bz2 -C /web/test1 7.1 通过vi编辑/web/test1/passwd文件将文件里为root单词全部替换成benet。 [root@localhost /]# vi /web/test1/etc/passwd :% s/root/benet/g 7.2 通过vi编辑 删除pass文件第1、5、10行。 [root@localhost ~]# vi pass 1 dd 5 dd 10 dd 7.3 在vi中显示:文件行号复制文件2 3 4行粘贴到以lp开头的行下。 [root@localhost ~]# vi pass 2 yy P 3 yy                   把光标移至2 3 4行行首按yy复制至ip开头行尾按p粘贴 P 4 yy p 7.4 通过vi编辑 查找文件内包含mail var等字符串,并记录所在行号。 [root@localhost ~]# vi pass /mail  /var ?mail ?var 7.5 通过vi编辑 快速跳转到文件的第二行,通过r 读取 /etc/hosts 文件的内容到第二行下。 2G                                             :r /etc/hosts 7.6将更改后的文件使用vim另存为/root/new_pass。 [root@localhost ~]# vi pass :w /root/new_pass 7.7将new_pass文件压缩成gz格式并改名为npass.gz文件。 [root@localhost ~]# gzip new_pass [root@localhost ~]# ls [root@localhost ~]# pwd /root [root@localhost ~]# mv /root/new_pass.gz /root/npass.gz mv:是否覆盖"/root/npass.gz"? y 8统计/dev 目录下的文件数量。 [root@localhost ~]# ls -l /dev|wc -l 158 9.1在/boot下查找文件名以vmlinuz开头的文件? [root@localhost ~]# find /boot -name "vmlinuz*" 9.2在/boot下查找文件大小大于3M 小于 20M 的文件 [root@localhost ~]# find /boot -size +3M -a -size -20M 10 请详细写出构建本地yum仓库的步骤?并在每行命令后面用自己的话做上中文注释? [root@localhost ~]# mount /dev/sr0/ /media/ [root@localhost ~]# cd /etc/yum.r* [root@localhost yum.repos.d]# mkdir a/ [root@localhost yum.repos.d]# mv C* a/ vi ./xjw.repo [cdrom]    //仓库名称 name=cdrom baseurl=file:///media   //指定rpm包的位置 enabled=1   //启用本地yum仓库 gpgcheck=0  //禁用gpg校验 [root@localhost ~]# yum -y clean all [root@localhost ~]# yum makecahe 11、用yum命令安装vsftpd,查询安装情况,最后卸载vsftpd,并再次查询卸载情况 [root@localhost ~]# yum -y install vsftpd [root@localhost ~]# rpm -q vsftpd [root@localhost ~]# yum -y remove vsftpd.x86_64 12、用rpm命令安装vsftpd,查询安装情况,最后卸载vsftpd,并再次查询卸载情况? [root@localhost ~]# rpm -q vsftpd 未安装软件包 vsftpd [root@localhost ~]# ls /media/Packages/ [root@localhost ~]# cd /media/Packages/ [root@localhost Packages]# find -name vsftpd* ./vsftpd-3.0.2-22.el7.x86_64.rpm [root@localhost Packages]# rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm [root@localhost Packages]# rpm -q vsftpd vsftpd-3.0.2-22.el7.x86_64 [root@localhost Packages]# rpm -e vsftpd [root@localhost Packages]# rpm -q vsftpd 未安装软件包 vsftpd 13、通过源码方式通过解包、配置、编译、安装四个步骤安装源码软件httpd-2.2.17.tar.gz?并进行测试?  [root@localhost ~]# tar xf httpd-2.2.17.tar.gz -C /usr/src [root@localhost ~]# cd /usr/src/httpd-2.2.17/ [root@localhost httpd-2.2.17]# ./configure --prefix=/usr/local/apache [root@localhost httpd-2.2.17]# vi /usr/local/apache/conf/httpd.conf 第97行开头#号删除  serverName www.example.com:80, wq退出保存 [root@localhost httpd-2.2.17]# /usr/local/apache/bin/apachectl start [root@localhost httpd-2.2.17]# yum -y install lynx   [root@localhost httpd-2.2.17]# lynx 127.0.0.1

转载于:https://www.cnblogs.com/ITXJW/p/11253734.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)