一、顯示當前系統上root、fedora或者user1用戶的默認shell;
[root@localhost ~]# grep -E “^(root|fedora|user1)” /etc/passwd | cut -d: -f7
/bin/bash
/bin/tcsh
/bin/bash
二、找出/etc/rc.d/init.d/functions文件中某單詞后面跟一小組括號的行,刑如:hello()
[root@localhost ~]# cat /etc/rc.d/init.d/functions | grep -o -E “\\(\)”
checkpid() {
daemon() {
killproc() {
pidfileofproc() {
三、使用echo命令輸出一個絕對路徑,使用grep取出基名
[root@localhost ~]# echo “/etc/tmp/test/” | grep -o -E “[^/]+/?$” | cut -d/ -f1
test
四、找出ifconfig命令結果中的1-255之間的數字;
[root@localhost ~]# ifconfig | grep -o -E “\”
29
31
192
168
106
1
五、查找/var目錄下屬主為root,且屬組為mail的所有文件或者目錄;
root@localhost ~]# find /var -user root -a -group mail
/var/spool/mail
/var/test1
/var/test
六、查找當前系統上沒有屬主或者屬組的文件;進一步:查找當前系統上沒有屬主或屬組,且最近3天內曾被被訪問過的文件或者目錄。
[root@localhost ~]# find / \( -nouser -o -nogroup \) -a -atime -3
七、查找/etc目錄下所有用戶都有寫權限的文件;
[root@localhost ~]# find /etc -perm +222
八、查找/etc目錄下大于1M,且類型為普通文件的所有文件。
[root@localhost ~]# find /etc -size +1M -a -type f
/etc/gconf/gconf.xml.defaults/%gconf-tree.xml
/etc/selinux/targeted/modules/active/policy.kern
/etc/selinux/targeted/policy/policy.24
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/87970