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

相关推荐

  • 堡垒机-麒麟开源堡垒机SSH公私钥认证配置文档

    1、进入SSH公私钥管理界面 操作步骤:进入系统,点击左侧导航资产管理,后边TAB标签导航SSH公私钥,如下图     2、批量导入SSH公私钥: SSH公私钥管理界面,点击下方”导入“,进入导入页面上传公私钥,     上传说明: 1) 讲所有的公私钥放到一个名为pvt的空文件夹中。 2) 在同样…

    Linux干货 2016-05-29
  • 如何修改linux系统主机名称及自动登录图形化界面

    编辑器:gedit(图形化编辑器)在图形界面编辑开机自动登录图形化界面(在工作中不能使用)Centos6  第一步:ls /etc/gdm/custom.conf第二步:nano /etc/gdm/custom.conf第三步:[daemon]第四步:AutomaticLoginEnable=trueAutomaticLogin=root第五步:按…

    Linux干货 2017-07-15
  • 第九周作业

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash declare -i sum_login=0 declare -i sum_nologin=0 while read line;do shell=$(echo $l…

    Linux干货 2017-03-05
  • 20160803普通权限与特殊权限及umask

    权限     任何一个可执行程序文件能不能启动为进程,取决发起者对程序文件是否拥有执行权限.即权限决定用户对文件或者目录的使用范围.在Linux系统中,root的权限是最高的,可操作的权限最大,通常情况下root账号只用于管理系统的重要信息,并不做日常维护工作,所以正确设定用户的权限对系统的安全性尤为重要. 普通权限: 文件目录只针对三类…

    Linux干货 2016-08-04
  • Linux运维之路-Linux基础学习二

    Linux系统的一切皆文件思想会帮助我们学习

    2017-11-18
  • CentOS6 网络管理之网卡配置及简单路由设置

    CentOS6中关于网络配置的命令有很多,本文将介绍几个平时最长用的几个命令,以及网卡IP地址的配置和简单路由配置。 1、经常使用的查看IP地址命令为 ifconfig,不跟参数的情况下默认查看所有已启用的网卡信息,如下图所示: 如果想查看具体某块网卡信息,则可以在ifconfig后面跟上网卡设备,如只查看eth0的信息则执行:ifconfig eht0 即…

    Linux干货 2016-09-05