博客作业网络班22期+第5周(9.5-9.11)

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

[root@MyCloudServer wjb]# egrep '^(root|fedora|user1)\>' /etc/passwd | cut -d: -f7
/bin/bash

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

[root@MyCloudServer ~]# grep '\<[[:alpah:]]\+()' /etc/rc.d/init.d/functions

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

[root@MyCloudServer ~]# echo "/etc/passwd" | egrep -o "[^/]+/?$"
passwd

[root@MyCloudServer ~]# echo "/etc/passwd" | egrep -o ".*/"
/etc/
4、找出ifconfig命令结果中的1-255之间数字

[root@MyCloudServer ~]# ifconfig | egrep -o '\<[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5]\>'
4
21
122
10
5、挑战题:写一个模式,能匹配合理的IP地址

[root@MyCloudServer ~]# ifconfig | egrep -o '[1-9]{3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
122.10.117.47
122.10.117.127
255.255.255.128
127.0.0.1
255.0.0.0
6、挑战题:写一个模式,能匹配出所有的邮件地址

[root@MyCloudServer ~]# /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i

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

[root@MyCloudServer ~]# find /var/ -user root -group mail
/var/spool/mail
8、查找当前系统上没有属主或属组的文件,进一步:查找当前系统上没有属主或属级,且最近3天内曾被访问过的文件或目录

[root@MyCloudServer ~]# find / -nouser -a -nogroup

[root@MyCloudServer ~]# find / -nouser -a -nogroup -mtime -3

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

[root@MyCloudServer ~]# find /etc -perm -222 -ls
132257    0 lrwxrwxrwx   1 root     root           15 Apr 30  2013 /etc/rc.sysinit -> rc.d/rc.sysinit
132258    0 lrwxrwxrwx   1 root     root           10 Apr 30  2013 /etc/rc0.d -> rc.d/rc0.d
132272    0 lrwxrwxrwx   1 root     root           11 Apr 30  2013 /etc/sysconfig/network-scripts/ifdown-isdn -> ifdown-ippp
132267
   0 lrwxrwxrwx   1 root     root           20 Apr 30  2013
/etc/sysconfig/network-scripts/ifdown -> ../../../sbin/ifdown
…..

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

[root@MyCloudServer ~]# find /etc/ -type f -a -size +1M
/etc/selinux/targeted/policy/policy.24
/etc/selinux/targeted/modules/active/policy.kern

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

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

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

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

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

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

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

[root@MyCloudServer ~]# find /etc/ -mtime -7 -a -not \( -user root -o -user hadoop \) -ls

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

(0)
wangjinbao5566wangjinbao5566
上一篇 2016-09-15 22:21
下一篇 2016-09-15 22:21

相关推荐

  • rsyslog同步history日志

    前言   由于公司业务是由公司内部开人员及外包团队共同开发,所以需要使用rsyslog对history日志做收集、审计。虽然搭建及配置非常简单,但是在日常运维工作中很实用,所以记录下,方便日后快速搭建。如果有错误,望大神指正。 syslog简介 syslog是Linux系统默认的日志守护进程。默认的syslog配置文件是/etc/sysl…

    Linux干货 2015-04-03
  • M20-1 8月5日 文本查看工具以及文本处理工

    一、文本查看工具:  cat,tac,rev cat用法:cat [option]..[FILE]..   cat选项:    -E:显示行结束符$    -n:对显示出的每一行进行编号    -A:显示所有控制符    -b:非空行编号   &nb…

    Linux干货 2016-08-08
  • shell脚本编程之变量详解

    什么是变量     变量是计算机内存的单元,其中存放的值可以改变。当Shell脚本需要保存一些信息时,如一个文件名或是一个数字,就把它存放在一个变量中。每个变量有一个名字,所以很容易引用它。 使用变量可以保存有用信息,使系统获知用户相关设置,变量也可以用于保存暂时信息。 变量:变量类型 作用:  &…

    Linux干货 2016-08-15
  • 马哥教育网络班21期+第三周课程练习

    列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登陆多次,只显示一次即可。 ~]# who|cut -d" " -f1|sort -u 2  取出最后登录当前系统的用户的相关信息。    ~]# id `last|head&nbs…

    Linux干货 2016-07-29
  • linux系统从windows xp上同步时间

    最近公司客户的调度系统GPS天文时钟出现故障,导致整个调度系统失去时间源,时间积累误差达十几分钟。去现场更换时钟很不方便,所有就想用现场的一台win xp(可上网)的远程机器做NTPserver,然后给linux系统对时。上网查了好多资料,终于找到了一个有效的解决方案,具体内容和步骤如下:首先下载一个Windows下的NTP服务软件。这个软件可以搭建wind…

    Linux干货 2015-03-27
  • 马哥教育网络班21期+第13周课程练习

    1、建立samba共享,共享目录为/data,要求:(描述完整的过程) 1)共享名为shared,工作组为magedu; 2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名; 3)添加samba用户gentoo,centos和u…

    Linux干货 2016-10-17