N22-第五周作业

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

 egrep "^(root|fedora|user1)" /etc/passwd|awk -F: '{printf "%-15s:%-s\n",$1,$7}'

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

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

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

echo "/etc/passwd"|grep -o "[^/]\+$"

    扩展:取出其路径名

 echo "/etc/passwd/dfsdf/sfddsf"|grep  -o ".*/"

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

ifconfig |egrep -o "[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]"

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

 ifconfig |egrep -o "[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5].[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5].[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5].[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]"

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

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

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

find /var/ -user root -a -group mail

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

find / -nouser -a -nogroup

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

find / -atime -3 -a -nouser -a -nogroup

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

find /etc -perm -111

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

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

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

find /etc/init.d -perm -113

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

 find /usr -not -user root -a -not -user bin -a -not -user hadoop

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

  find /etc -not -perm -222

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

find /etc/ -mtime -7 -not \( -user root -o -user hadoop \)
    find /etc/ -mtime -7 -not -user root -a -not -user hadoop

原创文章,作者:N22-北京-喜欢就好,如若转载,请注明出处:http://www.178linux.com/45551

(0)
N22-北京-喜欢就好N22-北京-喜欢就好
上一篇 2016-09-15 22:21
下一篇 2016-09-15 22:21

相关推荐

  • LAMP及nfs、samba的综合练习

    练习一: 配置第一台主机:服务端共享目录: [root@localhost /]# yum install nfs-utils [root@localhost /]# systemctl start rpcbind [root@localhost /]# sy…

    Linux干货 2016-10-24
  • 02葵花宝典之bash特性及文件入门

    文件管理 目录 命令替换 命令执行状态 元数据 时间戳

    2018-03-11
  • 第四周作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。[root@localhost ~]# cp -r /etc/skel/ /home/tuser1[root@localhost /]# chmod -R g=,o= /home/tuser1 2、编辑/etc/group文件…

    Linux干货 2017-03-04
  • N21-第二周博客

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 文件管理命令有复制、删除与移动:cp,mv,rm cp(复制档案或目录) [root@study ~]# cp [-adfilprsu] 源(source) 目标(destination) [root@study ~]# cp [options] source1 source2 s…

    Linux干货 2016-07-16
  • linux权限详解

    写在前面: 本博客详解命令chmod,  chowm,  chgrp,  umask,  install,  mktemp  权限管理: 进程文件访问权限应用模型: 进程的属主与文件属主是否相同,如果相同,则应用属主权限 否则,检查文件的属主是否属于文件的属组,如果是,则应用属主权限 否则,应用ot…

    Linux干货 2015-12-19
  • 马哥教育网络21期+第六周练习博客

    请详细总结vim编辑器的使用并完成以下练习题 1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; [root@localhost named]# cp /etc/rc.d/rc.sysinit /tmp/ [root@loc…

    Linux干货 2016-08-15

评论列表(1条)

  • 马哥教育
    马哥教育 2016-09-19 18:39

    抄串了吧,下次看看题目在抄,是匹配邮件地址