博客作业网络班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

相关推荐

  • 利用 yum 查找某个命令属于哪个包

    当我们在安装一个不熟悉的命令是,会遇到个问题:Error: Nothing to do 而你又不知道该命令的是属于哪个rom包,莫慌~我们可以借助一个叫yum的基于rpm的软件包管理器。 以 dig 这个命令为例,当我安装它时会出现如下情况  [root@localhost ~]# yum install dig  Loaded plug…

    Linux干货 2016-03-27
  • IO重定向

    I/O(IN Out)重定向(本来位置被改到别处位置):            指的改变默认输入输出的位置    程序:数据+指令  IO          可用于输入的设备:文件     &nbsp…

    Linux干货 2017-04-03
  • AWK实现求和、平均数、最小值、最大值

    1.简单的按列求和]$ cat test123125126]$ awk ‘{sum += $1}END {print sum}’ test2.对符合某些条件的行,按列求和]$ cat  testaaa 123bbb 125aaa 123aaa 123ccc 126对文件test中 第一列为aaa的行求和]$ awk &#82…

    Linux干货 2017-04-09
  • keepalived+lvs-dr实现高可用负载均衡

    keepalived+lvs-dr实现高可用负载均衡 实验拓扑 实验要求 RS1与RS2地址为172.18.27.201/202 VS1和VS2地址为172.18.27.103/200,VIP为172.18.27.254 VS1和VS2实现lvs-dr负载均衡及高可用性,且vs为sorry sever。 keepalived是单主模式。 实验步骤 各个主机安…

    2017-05-14
  • 删除并恢复

    1.删除/lib64/libc.so.6 ,并恢复之。 centos7.3:重启→进入救援模式→cd  lib64→cp libc.so.6  /mnt/sysimage/lib64 →exit,选择第二个白条(救援),即可恢复; centos6.9:重启→进入救援模式→cd  lib64→cp libc.so.6  …

    2017-06-11
  • 浅谈Linux终端类型

    Linux终端类型 作者:任飞鹏            日期:2016-10-13 终端是什么: 终端(Terminal)也称终端设备,是计算机网络中处于网络最外围的设备,主要用于用户信息的输入以及处理结果的输出等。 早期计算机系统中,由于计算机主机…

    Linux干货 2016-10-19