马哥教育网络班22期第5周课程作业

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

cat /etc/passwd | grep ^root | cut -d: -f7

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

cat /etc/rc.d/init.d/functions |grep -e "\<[[:alpha:]]*\>()"

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

    扩展:取出其路径名

echo "/etc/fstab" | grep -o "\<[[:alpha:]]*$"
echo "/etc/fstab" | grep -o "[/].*[/]"

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

[root@localhost ~]#  ifconfig | egrep -o "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5])"

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

ifconfig | egrep -o "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-5][0-5])\.){3}([0-9]|[1-9][
0-9]|1[0-9][0-9]|2[0-5][0-5])"

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

~]# egrep -i "[[:graph:]]+@[[:graph:]]+\.[a-z]+" 1.txt

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

[root@localhost ~]# find /var -user root -group mail -ls
67150324    0 drwxrwxr-x   2 root     mail           31 9月  9 18:32 /var/spool/mail

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

[root@localhost ~]#  find / -nouser -o -nogroup
find: ‘/proc/14232/task/14232/fd/6’: 没有那个文件或目录
find: ‘/proc/14232/task/14232/fdinfo/6’: 没有那个文件或目录
find: ‘/proc/14232/fd/6’: 没有那个文件或目录
find: ‘/proc/14232/fdinfo/6’: 没有那个文件或目录
/root/duqiu.sh

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

[root@localhost ~]#  find / -nouser -o -nogroup -a -atime -3
find: ‘/proc/14246/task/14246/fd/6’: 没有那个文件或目录
find: ‘/proc/14246/task/14246/fdinfo/6’: 没有那个文件或目录
find: ‘/proc/14246/fd/6’: 没有那个文件或目录
find: ‘/proc/14246/fdinfo/6’: 没有那个文件或目录
/root/duqiu.sh

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

 find /etc -perm  -111 -ls

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

[root@localhost ~]# find /etc -size +1M -type f -ls
34321825 6824 -r--r--r--   1 root     root      6984832 9月  9 16:05 /etc/udev/hwdb.bin
67923043 3772 -rw-r--r--   1 root     root      3858924 11月 21  2015 /etc/selinux/targeted

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

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

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

[root@localhost ~]# find /usr -not -user root -a -not -user bin -a -not -user hadoop -ls
67532253    0 drwx------   2 polkitd  root            6 6月 10  2014 /usr/share/polkit-1/ru
les.d

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

 find /etc/ -not -perm -777 ^C

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

[root@localhost ~]# find /etc -atime -7 -a -not -user root -o -not -user hadoop -ls
101092311    0 drwx------   2 polkitd  root           63 9月  9 15:50 /etc/polkit-1/rules.

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

(0)
杜邱杜邱
上一篇 2016-12-05 17:03
下一篇 2016-12-05 17:03

相关推荐

  • ☞RAID使用手册

    RAID使用手册 RAID演示

    Linux干货 2016-09-02
  • Nginx之ngx_http_proxy_module模块详解

    一、正反向代理简介       1、正向代理:局域网内的机器借助于代理服务器访问局域网外的网站          这时正向代理的功能:         &nbs…

    2017-06-25
  • vim文本编辑器使用

    vim文本编辑器使用

    2017-09-20
  • Linux 系统启动流程及bash 脚本编程练习

    马哥教育网络班23期 第10周课堂练习 Linux 系统启动流程及bash 脚本编程练习1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情) 2、为运行于虚拟机上的CentOS 6添加一块新硬件,提供两个主分区; (1)为硬盘新建两个主分区;并为其安装grub; (2)为硬盘的第一个主分区提供内核和ramdisk文件;为第二个分区提供r…

    Linux干货 2017-01-23
  • swap与dd命令使用详解

    处理交换文件和分区     交换分区是系统RAM 的补充 基本设置包括:     创建交换分区或者文件     使用mkswap 写入特殊签名     在/etc/fstab 文件中添加适当的条目 &…

    Linux干货 2017-04-30
  • 马哥教育网络班21期+第12周课程练习 ​

    1、请描述一次完整的http请求处理过程;   1)客户端和服务器端建立连接。服务器接收或者拒绝请求。   2)服务器端接收客户端请求。接收来自于网络的请求报文中对某资源的一次请求。对请求的处理响应,可分为单进程(启动一个进程处理请求,一次只处理一个)和多进程(并行启动多个进程,每个进程处理一个请求)。  &…

    Linux干货 2016-10-09