博客作业网络班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
下一篇 2016-09-15

相关推荐

  • centos系统启动流程详解

    centos系统启动流程详解 CentOS启动流程: POST 加电自检 主板上有一个ROM芯片,有只读程序,CPU被设计为一旦通电就会自动去找ROM芯片上的程序并运行,即检查各种硬件设备是否存在。 BootSequence 引导过程 加电自检后按BIOS中设定的次序查找各引导设备,第一个有引导程序的设备即是本次启动用到的设备 MBR(BootLoader)…

    Linux干货 2017-09-04
  • centos6.9的安装

    先准备一个安装虚拟机的的软件VMware Workstation Pro和光盘centos6.9和光盘 然后打开该软件,点击创建新的虚拟机   然后会出现一个新建虚拟机向导,选择典型,点下一步 继续点下一步   把虚拟机名称改成所装的版本 然后新建一个文件夹,点击浏览,接着点击这个新建的文件夹,这个文件夹就是虚拟机所装入的位置,…

    2017-07-15
  • 正则表达式入门

    正则表达式入门 谈到正则表达式,我们就得先了解一下POSIX。POSIX的全称是Portable Operating System Interface foruniX,它由一系列规范构成,定义了UNIX,linux操作系统应当支持的功能,它定义了BRE(Basic Regular Expression,基本型正则表达式)和ERE(Extended Regul…

    2017-07-29
  • 网络管理之nmcli命令的使用

    nmcli命令      地址配置工具:nmcli nmcli[ OPTIONS ] OBJECT { COMMAND | help }     device -show and manage network interfaces     …

    Linux干货 2016-09-19
  • 马哥教育网络20期第七周课程练习

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; fdisk /dev/sdb ; mke2fs -t ext4 -b 2048 -L MYDATA -m 2 –O acl /dev/sdb1 (2) 挂载至/data/mydata目录,要求挂载…

    Linux干货 2016-08-15
  • N22-第十二周作业

    1、请描述一次完整的http请求处理过程; (1)建立或处理连接:接受请求或拒绝请求 (2)接收请求:接收来自于网络上的主机请求报文中对某特定资源的一次请求的过程 (3)处理请求:对请求报文进行解析,获取客户端请求的资源及请求方法等相关信息 (4)访问资源:获取请求报文中请求的资源 (5)构建响应报文 (6)发送响应报文 (7)记录日志:访问日志和错误日志 …

    Linux干货 2016-11-04