马哥教育网络班21期-第五周课程练习

1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;

grep ^[[:space:]] /boot/grub/grub.conf

2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行;

egrep "^#[[:space:]]{1,}[[:alnum:]]{1,}" /etc/rc.d/rc.sysinit

3、打出netstat -tan命令执行结果中以‘LISTEN’,后或跟空白字符结尾的行;

netstat -tan|egrep "LISTEN[[:space:]]*"

4、添加用户bash, testbash, basher, nologin (此一个用户的shell为/sbin/nologin),而后找出当前系统上其用户名和默认shell相同的用户的信息;

useradd bash

useradd testbash

useradd basher

useradd nologin -s /sbin/nologin

egrep "(\<.*\>).*\1$" /etc/passwd

5、显示当前系统上root、fedora或user1用户的默认shell;

awk -F":" '/^root|^fedora|^user1/{print $1,$NF}' /etc/passwd

6、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();

grep "[[:alpha:]]\+()" /etc/rc.d/init.d/functions

7、使用echo命令输出一个绝对路径,使用grep取出其基名;

echo /usr/local/mysql/bin/mysql|grep -o "[^\/][[:alpha:]]\+$"

    扩展:取出其路径名

echo /usr/local/mysql/bin/mysql|grep -o "/.*/"

8、找出ifconfig命令结果中的1-255之间数字;

ifconfig |grep -o "[1-255]\+"|sort -nu

9、挑战题:写一个模式,能匹配合理的IP地址;

ifconfig |egrep -o "[1-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"

10、挑战题:写一个模式,能匹配出所有的邮件地址;

grep '.*@.*\.[[:alpha:]]\+$' mail.txt

11、查找/var目录下属主为root,且属组为mail的所有文件或目录;

find /var/ -user root -group mail

12、查找当前系统上没有属主或属组的文件;

find / -nouser -o -nogroup

     进一步:查找当前系统上没有属主或属组,且最近3天内曾被访问过的文件或目录;

find / \( -nouser -o -nogroup \) -atime -3

13、查找/etc目录下所有用户都有写权限的文件;

find /etc/ -type f -perm -222

14、查找/etc目录下大于1M,且类型为普通文件的所有文件;

find /etc/ -type f -size +1M

15、查找/etc/init.d/目录下,所有用户都有执行权限,且其它用户有写权限的文件;

find /etc/init.d/ -type f -perm -113

16、查找/usr目录下不属于root、bin或hadoop的文件;

find /usr/ ! \( -user root -o -user bin -o -user hadoop \)

find /usr/ -not \( -user root -o -user bin -o -user hadoop \)

17、查找/etc/目录下至少有一类用户没有写权限的文件;

find /etc/ -type f ! -perm -222

18、查找/etc目录下最近一周内其内容被修改过,且不属于root或hadoop的文件;

find /etc/ -type f ! \( -user root -o -user hadoop \) -mtime 7

原创文章,作者:N21_Ross_Geller,如若转载,请注明出处:http://www.178linux.com/28573

(0)
N21_Ross_GellerN21_Ross_Geller
上一篇 2016-08-08
下一篇 2016-08-08

相关推荐

  • Mysql cmake 编译安装、

    基于cmake的mysql安装 1.1 前言 从mysql5.5起,mysql源码安装的编译工具configure开始向cmake过渡。安装方式和之前的略有不同。在这里简单介绍总结下。 安装之前,检查下GNU make, GCC, Perl, libncurses5-dev,cmake-2.8.4是否都已经安装,如果没有安装,用yum install 安装补…

    Linux干货 2017-08-29
  • 最近了解到的命令

    ssh:secure  shell shell  人机交互的语言查询当前系统使用了哪个shell(接口程序) echo $SHELL 查询当前系统已安装的所有shell cat /etc/shells Shell提示符 whoami 显示当前的登录用户名 hostname 显示当前的主机名      pwd …

    Linux干货 2017-07-13
  • 系统基础之AWK详解

    GUN awk 文本处理三工具:grup,sed,awk     grep,egrep,fgrep:文本过滤工具     sed:行编辑器         模式空间,保持空间   …

    Linux干货 2016-09-21
  • ldirectord 结合ipvsadm 配置nat,dr模型

    ldirectord 结合ipvsadm 配置nat,dr模型  一、nat模型 1、 drector # wget ftp://172.16.0.1/pub/Sources/7.x86_64/crmsh/ldirectord-3.9.6-0rc1.1.1.x86_64.rpm # yum -y install nginx (同…

    Linux干货 2016-11-24
  • 启动流程与内核管理

    centos6和centos5启动流程与内核管理,启动过程中遇到的系统不能启动,各个阶段该怎么解决

    Linux干货 2018-01-02
  • 磁盘分区,raid,lvm,脚本编程_第七周练习

    Q1:创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@promote ~]# fdisk /dev/sdb        &n…

    Linux干货 2016-12-24

评论列表(1条)

  • 马哥教育
    马哥教育 2016-08-17 15:34

    写的很好,排版也很棒,加油