find 命令基礎練習

練習1 查找/tmp下,不是目錄,並且還不能是套接字類型的文件
find /tmp -not -type d -a -not -type s -ls
練習2 /tmp/test 目錄下,屬主即不是user1 ,也不是user2的文件
find /tmp/test -not ( -user user1 -o -user user2 ) -ls
練習 3 查找/var目錄下屬主爲rott並且屬組爲mail的所有文件
find /var -user root -group mail -ls
練習4 查找/usr 目錄下不屬於root ,bin 或student的文件
find /usr -not -user root -a -not -user bin -a -not -user student
find /user -not ( -user root -o -user bin -o -user student )
練習 5 查找/etc/目錄下最近一週內內容修改改過且不屬於root及student用戶的文件
find /etc -mtime -7 -a -not ( -user root -o -user student ) -ls
練習 6 查找當前系統上沒有屬主或者沒有屬組且最近一天內曾被訪問過的文件,並將其屬主屬組均修改爲root
find / -atime -1 -a -nouser -o -nogroup -exec chown root.root {} \;
練習 7 查/etc目錄下大於1M的文件,並將其文件名寫入/tmp/etc.largefiles文件中;
find /etc -size +1M >> /tmp/largefile.txt
練習8 查找/etc/目錄下所有用戶都沒有寫權限的文件,顯示出其詳細信息;
find /etc -not -perm /222 -ls
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章