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

相关推荐

  • RPM包管理——运维必备技能之一

    软件运行环境: API:Application Programming Interface     POSIX :Portable OS 程序源代码 –> 预处理 –> 编译 –> 汇编 –> 链接     …

    Linux干货 2016-08-21
  • 学习一个星期的沿途体会

    人生处处都是坑,只看跳的深不深。下面就来介绍介绍我跳的坑吧!当然我可没打算在此长眠 既然选择了Liunx,那对它的历史就得了解清楚。就如同我们结婚,既然选择了对方,那就要了解他的过去,包容他的未来。           Linux操作系统是一个叫Linus Torvalds的大学生在1991年开发而来。当然,…

    2017-07-16
  • 进程管理常用命令

    Linux系统上的进程查看及管理工具:pstree,ps,pidof,pgrep,top,htop,glances,pmap,vmstat,dstat,kill,pkill,job,bg,fg,nohup,nice,renice,killall,…CentOS 5 :SysV initCentOS 6 :upstartCentOS 7 :syst…

    Linux干货 2017-05-17
  • 基于BIND实现的DNS正反解析及主从DNS的配置

    基于BIND实现的DNS正反解析及主从DNS的配置 标签: DNS正反解析 DNS主从复制 测试环境 准备2台虚拟机,一台为主DNS,IP地址为:192.168.103.161。另一台为从DNS,IP地址为:192.168.103.162两台都装好bind,所需包有:bind,bind-utils,bind-libs 主DNS的配置文件 配置主文件/etc/…

    Linux干货 2016-04-11
  • 浅谈用户名和权限

        小编已经写了两篇博客了,却忘了自我介绍,咳咳咳(隆zhuang重qiang介zuo绍shi)一下:翠衣薄纱如花艳,柳眉凤眼俏佳人说的就是我!不扯了其实,小编拥有一个四口之家,那么小编今天就借家献佛给你们讲讲用户组和权限。     所属主(me):一般为文件的创建者,谁创建了该文件,就天然的成…

    Linux干货 2017-07-30
  • Apache配置压缩优化时报错——undefined symbol: inflateEnd

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://nolinux.blog.51cto.com/4824967/1345264    圣诞都过了,好久没来51发博文了。最近一直在忙考试和其他一些私人事务,感觉长期不发博文,有点不好。不是不发,实在是最近…

    Linux干货 2016-08-15