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

相关推荐

  • centos启动流程

    1、加电自检(power on system test POST) 加电,就是按下电源键使电脑主机通电,在诸多硬件设备中有一个被称为CMOS设备在计算机启动的过程中起到了至关重要的作用,CMOS在加电之后会启动保存在它上面的BIOS程序,即基本输入输出系统(Basic Input Output System)。自检,主要是检测各…

    Linux干货 2016-09-11
  • 进程和计划任务

    1、进程概念 内核的功用:进程管理、文件系统、网络功能、内存管理、驱动程序、安全功能等; 进程是运行中的程序的一个副本,是被载入内存的一个指令集合; 进程ID(PID )号码被用来标记各个进程; UID、GID 和SELinux 语境决定对文件系统的存取和访问权限,这些权限通常从执行进程的用户来继承并且存在生命周期; task struct:Linux内核存…

    Linux干货 2016-09-13
  • iptables/netfilter入门到进阶

    防火墙的概念 Firewall:工作于主机或网络边缘,对于进出本主机或网络的报文根据事先定义的规则作匹配检测,对于更改被规则匹配到的报文做出相应处理的组件 网络层防火墙(包过滤防火墙): 优点:对用户来说透明,处理速度快且易于防护 缺点:一旦黑客突破防火墙,就可以请以伪造数据包源地址、目的地址和IP端口号 代理服务型防火墙(Proxy Service) 优点…

    2017-06-17
  • Linux终端类型

    希望可以通过本文让网友们对linux的终端类型有一个清晰的认识!

    Linux干货 2016-10-14
  • Week9’s homework

    Week9's homework 1、写一个脚本(1)判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin)(2)分别统计两类用户的个数;通过字符串比较来实现。 #!/bin/bash # for i in $(cat /etc/passwd |…

    Linux干货 2016-12-24
  • Ansible Playbook Roles 和 Include 声明-手稿

    Edit Ansible Playbook Roles 和 Include 声明 Ansible Playbook Roles 和 Include 声明 1. Introduction 2. Task Include Files And Encouraging Reuse 3. Roles 4. Role Default Variables 5. Role …

    Linux干货 2016-03-28