博客作業網絡班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.www58058.com/45755

(0)
wangjinbao5566wangjinbao5566
上一篇 2016-09-15 22:20
下一篇 2016-09-15 22:21

相關推薦

  • 單向加密原理

      單向加密算法對數據進行加密的過程分為兩個步驟:   一、添加特征碼           上圖中說明了為數據添加特征碼的步驟:       1、使用單向算法計算出特征碼       2、使用私鑰來加密特征碼   &nb…

    Linux干貨 2016-02-24
  • 詳解Ntbackup的五種備份方式(下)

    原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。http://jeffyyko.blog.51cto.com/28563/145644 繼續上文。   四、差異備份(Differental Backup)     差異備份是…

    Linux干貨 2015-03-26
  • RPM和YUM的使用說明

    一、RPM包管理程序 centos系統上使用rpm命令管理程序包: 安裝、卸載、升級、查詢、校驗、數據庫維護 RPM包安裝選項:   –test:測試安裝,但不真正執行安裝   –nodeps:忽略依賴關系   –nosignature:不檢查來源合法性   –nodig…

    Linux干貨 2016-08-24
  • 如何在 Linux 下大量屏蔽惡意 IP 地址

    很多情況下,你可能需要在Linux下屏蔽IP地址。比如,作為一個終端用戶,你可能想要免受間諜軟件或者IP追蹤的困擾?;蛘弋斈阍谶\行P2P軟件時。你可能想要過濾反P2P活動的網絡鏈接。如果你是一名系統管理員,你可能想要禁止垃圾IP地址訪問你們的公司郵件服務器?;蛘吣阋蛞恍┰蛳胍鼓承﹪以L問你的web服務。在許多情況下,然而,你的IP地址屏蔽列表可能會很快…

    Linux干貨 2015-02-26
  • 第三周作業

    博客具體內容請移步博客園: http://www.cnblogs.com/ITOps/p/6204549.html

    Linux干貨 2016-12-20
  • bash腳本基礎認知

    編程基礎:程序:指令+數據                過程式:以指令為中心,數據服務于指令              &nbs…

    Linux干貨 2017-03-02
欧美性久久久久