find 命令練習

2021-10-22 08:32:19 字數 995 閱讀 9894

查詢/etc目錄下大於1m且型別為普通檔案的所有檔案

[root@nginx ~]

# find /etc/ -size +1m -type f | ls -lh

total 8.0k

-rw-------. 1 root root 1.4k sep 29 2019 anaconda-ks.cfg

-rw-r--r--. 1 root root 1.5k sep 29 2019 initial-setup-ks.cfg

打包/etc/目錄下面所有conf結尾的檔案,壓縮包名稱為當天的時間,並拷貝到/usr/local/src目錄備份。

[root@nginx ~]

# find /etc/ -maxdepth 1 -name *.conf | xargs tar -cf /usr/local/src/`date +%f`.tar

tar: removing leading `/' from member names

tar: removing leading `

/' from hard link targets

[root@nginx ~]

# ls /usr/local/src/

2021-03-16.tar

查詢當前系統上沒有屬主或屬組,且最近乙個週內曾被訪問過的檔案或目錄

root@testsvr:~# find / -nouser -a -nogroup -a -atime -7 2> /dev/null

/var/cache/private/fwupdmgr

/var/cache/private/fwupdmgr/fwupd

查詢/etc目錄下至少有一類使用者沒有執行許可權的檔案

root@testsvr:~# find /etc -not -perm -111
* 非所有人都有執行許可權,即表示,至少有乙個人沒有許可權

find命令詳 解 練 習

find命令用於按照指定條件來查詢檔案,格式為 find 查詢路徑 尋找條件 操作 引數作用 name 匹配名稱 perm 匹配許可權 mode為完全匹配,mode為包含即可 user 匹配所有者 group 匹配所有組 mtime n n 匹配修改內容的時間 n指n天以內,n指n天以 前 atim...

find 查詢練習

1 查詢 var目錄下屬主為root,且屬組為mail的所有檔案 有目錄沒有檔案,type f 14 29 30 root centos7 find var user root a group mail ls 67142179 4 drwxrwxr x 2 root mail 4096 apr 7 ...

find 命令 Linux命令篇 find命令

find name txt o name pdf print演示結果 find regex txt pdf iregex 忽略大小寫的正則 查詢所有非txt文字 find name txt print演示結果 列印出當前目錄的檔案 深度為1 find maxdepth 1 type f演示結果 5....