• chapter02


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

    [root@localhost ~]# cat -n /etc/ssh/sshd_config

         1 # $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $

         2

         3 # This is the sshd server system-wide configuration file.  See

         4 # sshd_config(5) for more information.

         5

         6 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin

         7

    8 # The strategy used for options in the default sshd_config shipped with

    cat:将该文件下的内容以正向的形式显示出来,文件中的空白行也会标记行号。

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

    # ForceCommand cvs server

    # PermitTTY no

    # AllowTcpForwarding no

    # X11Forwarding no

    #Match User anoncvs

    # Example of overriding settings on a per-user basis

    Subsystem sftp /usr/libexec/openssh/sftp-server

    # override default of no subsystems

    AcceptEnv XMODIFIERS

    tac:将该文件下的内容反向显示出来,与cat相反

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

         1 # $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $

           

         2 # This is the sshd server system-wide configuration file.  See

         3 # sshd_config(5) for more information.

           

         4 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin

           

    5 # The strategy used for options in the default sshd_config shipped with

    nl:正向显示文件内容,但空白行不标行号

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

    [root@localhost ~]# more /etc/ssh/sshd_config

    [root@localhost ~]# less /etc/ssh/sshd_config

    相同之处:moreless都是全屏方式分页显示内容,命令的用法一样,都可以上下翻动,退出都是按q

    不同之处:

    MoreEnter键向上翻动一行,Shift+PgUp/PgDn键上下翻动一行,空格键向下翻动一页。

    LessPgUp/PgDn上下翻行;/键查找内容,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 ~]# cat /root/20_pass.txt | wc -l

    20

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

    [root@localhost ~]# cat /root/pass_15.txt | wc -l

    15

    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、练习使用grepegrep

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

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

            inet 192.168.100.104  netmask 255.255.255.0  broadcast 192.168.100.255

            inet6 fe80::20c:29ff:fe97:eb45  prefixlen 64  scopeid 0x20<link>

            inet 127.0.0.1  netmask 255.0.0.0

            inet6 ::1  prefixlen 128  scopeid 0x10<host>

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

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

    [root@localhost ~]# cat /root/pass | wc -l

    20

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

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

    5

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

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

    root:x:0:0:root:/root:/bin/bash

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

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

     

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

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

    tar: 从成员名中删除开头的“/

    /etc/passwd

    [root@localhost ~]# ls

    20_pass.txt      is the sshd server system-wide configuration file. See  公共  图片  音乐

    anaconda-ks.cfg  pass                                                    模板  文档  桌面

    file.tar.gz      pass_15.txt  

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

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

    tar: 从成员名中删除开头的“/

    /etc/passwd

    [root@localhost ~]# ls

    20_pass.txt      file.tar.gz                                             pass_15.txt  视频  下载

    anaconda-ks.cfg  is the sshd server system-wide configuration file. See  公共         图片  音乐

    file.tar.bz2     pass     

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

    [root@localhost ~]# mkdir -p /web/test1

    [root@localhost ~]# ls /web/

    test1

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

    [root@localhost ~]# ls /web/test1

    etc

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

    :% s/root/benet/g

    7.2 通过vi编辑 删除pass文件第1510行。

    :set nu   //显示行号

    1     定位到第一行按dd删除

    5     定位到第一行按dd删除

    10    定位到第一行按dd删除

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

    :set nu   //显示行号

    将光标移动到第二行按 3yy 就把包括光标所在行的三行复制到剪贴板

    /lp  //查找包含Ip开头的行

    将光标移动到第五行按 p 粘贴到该行下

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

    :set nu   //显示行号

    /mail 查找mail字符串所在的行:9

    /var  查找var字符串所在的行:18

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

    2  //将光标移动到第二行

    r /etc/hosts  //读取/etc/hosts的文件到第二行下

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

    :w /root/new_pass

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

    [root@localhost ~]# gzip /root/new_pass

    gzip: /root/new_pass: No such file or directory

    [root@localhost ~]# ls

    20_pass.txt      is the sshd server system-wide configuration file. See  v     图片  桌面

    anaconda-ks.cfg  new_pass.gz                                             公共  文档

    file.tar.bz2     pass                                                    模板  下载

    file.tar.gz      pass_15.txt     

    [root@localhost ~]# mv new_pass.gz npass.gz

    [root@localhost ~]# ls

    20_pass.txt      is the sshd server system-wide configuration file. See  pass_15.txt  图片  桌面

    anaconda-ks.cfg  mv                                                      公共         文档

    file.tar.bz2     npass.gz                                                模板         下载

    file.tar.gz      pass         

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

    [root@localhost ~]# ls -al /dev | grep -v "^d" | wc -l

    142

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

    [root@localhost ~]# ls -a /boot | grep "^vmlinuz"

    vmlinuz-0-rescue-838f26c3e2384f26aae18f06e79bf4bb

    vmlinuz-3.10.0-229.el7.x86_64

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

    [root@localhost ~]# find /boot -size +3M -a -size -20M

    /boot/vmlinuz-3.10.0-229.el7.x86_64

    /boot/vmlinuz-0-rescue-838f26c3e2384f26aae18f06e79bf4bb

    /boot/initramfs-3.10.0-229.el7.x86_64.img

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

    umount  /etc/sr0  //卸载光盘

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

    ls  /media/   //查看

     

    cd  /etc/yum.r*    //构建本地yum仓库

    mkdir  a/    //创建文件夹

    mv  C*  a/

    vi  ./local.repo   //创建本地yum仓库文档

    [cdrom]    //仓库名称

    name=cdrom

    bareurl=file:///media    //指定rap包安装

    enabled=1     //启用本地yum仓库

    gpgcheck=0   //禁用pgp校验

     

    yum  -y  clean  all   //清除yum缓存

    yum  makecache    //重建yum缓存

    rpm  -q  vsftpd    //查询是否安装vsftpd

    yum  -y  install  vsftpd    //yum安装vsftpd

    rpm  -q  vsftpd      //查询是否安装vsftpd

    yum  -y  remove  vsftpd   //yum卸载vsftpd

    rpm  -q  vsftpd

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

    [root@localhost yum.repos.d]# yum -y install vsftpd

    已加载插件:fastestmirror, langpacks

    Loading mirror speeds from cached hostfile

    正在解决依赖关系

    --> 正在检查事务

    ---> 软件包 vsftpd.x86_64.0.3.0.2-9.el7 将被 安装

    --> 解决依赖关系完成

    [root@localhost yum.repos.d]# rpm -q vsftpd

    vsftpd-3.0.2-9.el7.x86_64

    [root@localhost yum.repos.d]# yum -y remove vsftpd

    已加载插件:fastestmirror, langpacks

    正在解决依赖关系

    --> 正在检查事务

    ---> 软件包 vsftpd.x86_64.0.3.0.2-9.el7 将被 删除

    --> 解决依赖关系完成

    [root@localhost yum.repos.d]# rpm -q vsftpd

    未安装软件包 vsftpd

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

    [root@localhost Packages]# rpm -vih vsftpd-3.0.2-9.el7.x86_64.rpm 

    警告:vsftpd-3.0.2-9.el7.x86_64.rpm: V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY

    准备中...                          ################################# [100%]

    正在升级/安装...

       1:vsftpd-3.0.2-9.el7               ################################# [100%]

    [root@localhost Packages]# rpm -q vsftpd

    vsftpd-3.0.2-9.el7.x86_64

    [root@localhost Packages]# rpm -e vsftpd

    [root@localhost Packages]# rpm -q vsftpd

    未安装软件包 vsftpd

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

    1、将软件包导入(直接拖过去)

    2、查看gccgcc-c++make是否安装

    gcc  --version

    yum  -y  install  gcc

    gcc-c++  --version

    yum  -y  install  gcc-c++

    make  --version

    yum  -y  install  make

    3、将源码解压到/usr/src/目录下

    tar  -xf  httpd-2.2.17.tar.gz  -C  /usr/src/

    cd  /usr/src/

    ls

    cd  httpd-2.2.17  

    ./configure --prefix=/usr/local/apache/

    5、编译(源码包目录下)

    make

    6、安装(源码包目录下)

    make  install

    7、修改配置文件

    [root@localhost httpd-2.2.17]# cd /usr/local/apache/conf

    [root@localhost conf]# ls

    extra  httpd.conf  magic  mime.types  original

    ServerName打开

    [root@localhost conf]# vi httpd.conf 

    /ServerName

    n

    Yy

    p     

    8、启动

    [root@localhost conf]# /usr/local/apache/bin/apachectl start

    9、安装lynx

    [root@localhost conf]# lynx 127.0.0.1

    bash: lynx: 未找到命令...

    [root@localhost conf]# yum -y install lynx

    已加载插件:fastestmirror, langpacks

    Loading mirror speeds from cached hostfile

    正在解决依赖关系

    --> 正在检查事务

    ---> 软件包 lynx.x86_64.0.2.8.8-0.3.dev15.el7 将被 安装

    --> 解决依赖关系完成

    [root@localhost conf]# lynx 127.0.0.1

    本文为作者 三岁半的胖啊 的原创,转载请标明出处 链接:https://home.cnblogs.com/u/tanxiaojuncom/
  • 相关阅读:
    code第一部分数组:第十七题 爬楼梯问题
    code第一部分数组:第十六题 数组表示数,加一操作
    code第一部分数组:第十五题 矩阵翻转(图像翻转)
    code第一部分:数组 第十四题 雨水问题
    code第一部分数组:第十题:移除数组中目标元素
    [java 2020-04-24] Maven多模块项目+SpringBoot,编译失败:程序包xxx不存在
    [java 2020-04-24] springboot生成的jar包没有主类和依赖jar包
    [java 2019-12-16] SimpleDateFormat格式化跨年显示格式错误
    [2019-11-22]马说
    [linux 2019-10-23] linux可以创建多少个用户
  • 原文地址:https://www.cnblogs.com/tanxiaojuncom/p/11252321.html
Copyright © 2020-2023  润新知