马哥教育网络班第21期+第五周课程作业

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

[root@redhat6 ~]# grep '^[[:space:]]\+' /boot/grub/grub.conf

 

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

[root@redhat6 ~]# grep '^#[[:space:]]\+[^[:space:]]\+' /etc/rc.d/rc.sysinit

 

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

[root@redhat6 ~]# netstat -tan | grep "LISTEN*[[:space:]]"

 

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

[root@redhat6 ~]# useradd bash;useradd testbash;useradd basher;useradd -s /sbin/nologin nologin

[root@redhat6 ~]#grep '^\([[:alnum:]]\+\>\).*\1$' /etc/passwd

 

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

[root@redhat6 ~]# egrep "^(root|fedora|user1)" /etc/passwd|cut -d: -f1,7

 

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

[root@redhat6 ~]# egrep -o ".*[[:alpha:]]+\(\)" /etc/rc.d/init.d/functions

 

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

[root@redhat6 ~]# echo "/etc/sysconfig/network-scripts/ifcfg-eth0" | grep -E -o "[^/]+/?$"

 

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

[root@redhat6 ~]# ifconfig | egrep -o  '([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'

 

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

[root@redhat6 ~]# ifconfig | egrep -o '[1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

 

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

[root@redhat6 ~]# cat test01.txt | grep '.*@.*\.[[:alpha:]]\+$'

 

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

[root@redhat6 ~]# find /var -user root -a -group mail -ls

 

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

[root@redhat6 ~]# # find / -nouser -o -nogroup –ls

[root@redhat6 ~]# find / \( -nouser -o -nogroup \) -a -atime -3 –ls

 

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

[root@redhat6 ~]# find /etc -perm -222 –ls

 

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

[root@redhat6 ~]# find /etc -size +1M -type f

 

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

[root@redhat6 ~]# find /etc/init.d -perm -113

 

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

[root@redhat6 ~]# find /usr -not \( -user root -o -user bin -o -user hadoop \) -ls

 

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

[root@redhat6 ~]# find /etc -not -perm -222

 

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

[root@redhat6 ~]# find /etc/ -atime 7 -not \( -user root -o -user hadoop \) -ls

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

(0)
LionelLionel
上一篇 2016-08-08 11:52
下一篇 2016-08-08 16:03

相关推荐

  • nginx

    http http协议:web服务器(类似于httpd)、http reverse proxy(类似于httpd)、imap/pop3 reverse proxy NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/P…

    Linux干货 2017-06-25
  • N26 第四周作业

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

    Linux干货 2017-01-23
  • Linus:利用二级指针删除单向链表

    感谢网友full_of_bull投递此文(注:此文最初发表在这个这里,我对原文后半段修改了许多,并加入了插图) Linus大婶在slashdot上回答一些编程爱好者的提问,其中一个人问他什么样的代码是他所喜好的,大婶表述了自己一些观点之后,举了一个指针的例子,解释了什么才是core low-level coding。 下面是Linus的教学原文及翻译—— “…

    Linux干货 2016-07-10
  • redis主从复制(4)— client buffer

    1、 client buffer的设计 redis server以单进程的方式处理接收到的请求,而redis完成请求有些工作比较慢,比如网络IO和磁盘IO等比较慢的操作。redis为了提高处理客户端请求的响应时间,做了很多优化。比如网络io和磁盘io是异步完成、使用后台进程完成bgsave和bgrewriteaof工作,在server端为客户提供读buffe…

    Linux干货 2016-03-28
  • rsync+inotify实现数据同步——单向传输

    实验环境:<从A主机推送数据到B主机[B主机可以有多个]> A主机:10.1.43.102 B主机:10.1.43.103 配置流程: —rsyncserver—- <B主机上配置> 1.vim /etc/rsyncd.conf(用户,目录,模块,虚拟用户及密码文件) vim /etc/rsyncd.…

    Linux干货 2016-10-27
  • python第二周

    #python数据结构(list) ## 分类 数值型:int、float、complex、bool 序列对象:字符串 str   列表  list   元组  tuple 键值对: 集合 set   字典 dict   ## 数字的处理函数 math.e  math.pi: 自如常数和π round():  四舍六入五去偶 floor():  取…

    Linux干货 2017-09-23

评论列表(1条)

  • 马哥教育
    马哥教育 2016-08-08 16:49

    写的很好,排版还可以在漂亮一点,加油,ip地址匹配不对