• liunx系统02


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

    [root@localhost ~]# nl  /etc/ssh/sshd_config  查看文件中的内容,并排出序列号,空格除外。

    [root@localhost ~]# tac  /etc/ssh/sshd_config  查看文件中的内容 倒叙排列。

    [root@localhost ~]# cat  /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   与more基本相同,但扩展功能更多。

    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 -lwc /etc/hosts

    5、练习使用grep和egrep

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

    [root@localhost ~]# ifconfig | grep 'inet' | grep -o 't.* n' | grep -o " .* "

    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' /etc/passwd | grep 'nologin' | wc -l

    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/ss’hd_config |grep -v '^$'

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

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

    [root@localhost ~]# cd /etc

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

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

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

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

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

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

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

    # vi /web/test1/passwd

    :% s/root/benet/g    

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

    Vi pass

    :set nu

    :10d

    :5d

    :1d

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

    :2,4 co 5

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

    :set nu

    /mail

    /var        

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

    #2G

    :r /etc/hosts

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

          2 bin:x:1:1:bin:/bin:/sbin/nologin

          3 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

          4 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

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

    :w / root/new_pass。

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

    [root@localhost ~]# tar -czf npass.gz new_pass

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

    [root@localhost ~]# ls /dev -l | wc -l

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

    [root@localhost boot]# find /boot -name "vmlinuz*"

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

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

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

     

    cd /etc/yum.r*   进入etc下yum文件夹

    mkdir a/      在yum文件夹中创建名字为a的文件夹

    mv C* a/      在yum文件夹中将开头带C的文件全部移动到文件夹a中

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

    [cdrom]    仓库名称

    name=cdrom 仓库名称=cdrom

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

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

    gpgcheck=0  //禁用gpg校验

     

    yum -y clean all   清除yum缓存

    yum makecache   重建yum缓存

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

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

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

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

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

    [root@localhost yum.repos.d]# rpm -ivh /media/Packages/vsftpd-3.0.2-25.el7.x86_64.rpm

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

    [root@localhost yum.repos.d]# rpm -e vsftpd    卸载

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

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

    [root@localhost ~]# yum -y install gcc-c++ gcc

    [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]#make

    [root@localhost httpd-2.2.17]#make install

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

    [root@localhost conf]# cp httpd.conf httpd.conf.bak

    [root@localhost conf]# vi httpd.conf

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

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

    [root@localhost conf]# lynx 127.0.0.1

  • 相关阅读:
    Day18-lvs
    mysql日志
    【杂文】我们都有光明的前途(回忆录)
    【杂文】银色的 NOI2020(退役记)
    【杂文】SCOI2020 游记
    【学习笔记】字符串—广义后缀自动机
    【学习笔记】数论、数学—常见定理、结论、性质汇总
    【杂文】随心一记
    【杂文】CSP2019 蒟蒻AFO(假)记
    【模板整合计划】目录
  • 原文地址:https://www.cnblogs.com/shenchunbo/p/11252661.html
Copyright © 2020-2023  润新知