N22-第5周博客作业

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

grep -E "^(root|fedora|user1)\>" /etc/passwd | cut -d: -f7

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

grep -E -o "[[:alnum:]]+\(\)" /etc/rc.d/init.d/functions

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

[root@www scripts]# echo /etc/sysconfig/ | grep -E -o "[^/]+/?$"
sysconfig/
[root@www scripts]# echo /etc/sysconfig/ | grep -o "^.*/"
/etc/sysconfig/

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

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

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

[root@www scripts]# ifconfig | grep -o '\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}'
192.168.5.171
255.255.255.0
192.168.5.255
127.0.0.1
255.0.0.0
192.168.122.1
255.255.255.0
192.168.122.255

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

egrep -o "[[:alnum:]]+\@[[:alnum:]]+\.[[:alnum:]]"

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

[root@www scripts]# find /var -user "root" -a -group "mail"
/var/spool/mail
/var/spool/mail/root

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

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

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

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

find /etc -perm -222 -exec ls -lh {} \;

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

find /etc/ -size +1M -type f -exec ls -lh {} \;

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

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

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

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

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

find /etc -not -perm 222 -type f -ls

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

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

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

(0)
zhuckeezhuckee
上一篇 2016-12-05
下一篇 2016-12-05

相关推荐

  • output_6588

    Bahsegel 2025 Güncel İncelemesi Bahsegel online bahis sitesi, bu yıl itibarıyla internet üzerinden casino endüstrisinde bahsegeltr.pro adından sıkça söz ettiren bir site olmuştur. …

    Linux干货 6天前
  • 网络班21期第四周作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。          mkdir /home/tuser1        &n…

    Linux干货 2016-08-22
  • bash 循环和函数

    回顾: 循环 循环控制:break,continuewhile , for循环的特殊用法for (());do     循环体donewhile read VARAIBLE;do     循环体done <&nbs…

    Linux干货 2016-08-24
  • grep的使用以及正则表达式

    正则表达式以及grep的使用 grep是一种文本过滤工具(模式:pattern)基本使用用法如下: grep [option] PATTERN FILE grep [OPTIONS] [-e PATTERN | -f FILE] [FILE…] –colour=auto:对匹配到的文本着色 -i:ignorecase 忽略字符大小写 -o:仅显示匹配到…

    Linux干货 2017-08-21
  • 网络N23期第一周(计算机的组成及功能及Linux的发行版等)

    一. 描述计算机的组成及功能 计算机由五大硬件组成:” 运算器 + 控制器 + 储存器 + 输入设备 + 输出设备” 。 运算器(Datapath):运算器的功能是对数据进行各种算术运算和逻辑运算,即对数据进行加工处理。 控制器(Control):是整个计算机的中枢神经,其功能是对程序规定的控制信息进行解释,根据其要求进行控制,调度程序、数据、地址,协调计算…

    Linux干货 2016-09-22