N23-第五周博客作业

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

[root@localhost ~]# cat /etc/passwd | egrep "^root\>" | cut -d: -f1,7

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

[root@localhost ~]# cat /etc/rc.d/init.d/functions | egrep "[a-z]+\(\)"

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

基名:

[root@localhost ~]# echo "/tmp/test/floor/a/welcome.text" | grep -o -E "[^\/]+$"

路径名:

[root@localhost ~]# echo "/tmp/test/floor/a/welcome.text" | grep -o -E "^\/.*+\/"

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

[root@localhost ~]# ifconfig | grep -E -o "\<([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\>"



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

~]# grep -E "[1-9]+\.[1-9]+\.[1-9]+\.[1-9]+"

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

~]# grep -E "^[a-z]+.*@[:alnum:]+.*\.+[:alnum:]$"

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

[root@localhost ~]# find /vat -user root -a -group mail -ls

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

1): [root@localhost ~]# find / -nouser -o -nogroup -ls

2): [root@localhost ~]# find / \( -nouser -o -nogroup \) -a -atime -3 -ls


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

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

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

[root@localhost ~]# find /etc -type f -size +1M -exec ls -hl {} \;


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

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


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

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

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

[root@localhost ~]# find /etc -not -perm /222 -exec ls -l {} \;

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

[root@localhost ~]# find -not \( -user root -o -user hadoop \) -mtime -7

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

(0)
hotpointhotpoint
上一篇 2016-12-05 17:04
下一篇 2016-12-05 17:04

相关推荐

  • shell脚本编程的一些好习惯

    shell脚本编程的一些好习惯 1.命名规则   脚本命名以.sh结尾,名称尽量见名之意。以下是几种可供参考的脚本命名风格。通过以下清新脱俗的风格,读者能够很easy的明白脚本的作用。 clearlog.sh ClearLog.sh clearSql.sh snmp_install.sh Monitor.sh 2.脚本信息   为脚本加入…

    Linux干货 2017-04-14
  • CentOS 6.5下编译安装httpd+mysql+php过程实录

    一、安装环境     Linux系统:CentOS 6.5     Apache版本:http-2.4.12     MySQL版本:MySQL 5.6.24     PHP版本:PHP-5.6.8 …

    Linux干货 2015-05-18
  • iptables/netfilter入门到进阶

    防火墙的概念 Firewall:工作于主机或网络边缘,对于进出本主机或网络的报文根据事先定义的规则作匹配检测,对于更改被规则匹配到的报文做出相应处理的组件 网络层防火墙(包过滤防火墙): 优点:对用户来说透明,处理速度快且易于防护 缺点:一旦黑客突破防火墙,就可以请以伪造数据包源地址、目的地址和IP端口号 代理服务型防火墙(Proxy Service) 优点…

    2017-06-17
  • shell编程、查找命令、压缩文件工具

    shell编程、查找命令、压缩文件工具  shell编程 一、条件测试  1、判断某需求是否满足,需要由测试机制来实现。    测试命令:  ·test Expression  ·[ EXPRESSION ]  ·[[ EXPRESSION ]]   &nbs…

    Linux干货 2016-08-15
  • Linux终端类型

    希望可以通过本文让网友们对linux的终端类型有一个清晰的认识!

    Linux干货 2016-10-14
  • find用法及德·摩根定律

    德·摩根定律   奥古斯都·德·摩根首先发现了在逻辑命题中存在着下面这些关系:      非(P且Q)=非P或非Q      非(P或Q)=非P且非Q 上述逻辑命题可以解释为:    not ( P and Q)=not P or not Q    …

    Linux干货 2016-08-18