centos 如何 根據(jù)文件權(quán)限查找文件
下面的操作時(shí)合理的:
找到具有指定權(quán)限的文件
忽略其他權(quán)限位,檢查是否和指定權(quán)限匹配
根據(jù)給定的八進(jìn)制/符號(hào)表達(dá)的權(quán)限搜索
此例中,假設(shè)目錄包含以下文件。注意這些文件的權(quán)限不同。
ls -l
total 0
-rwxrwxrwx 1 root root 0 2009-02-19 20:31 all_for_all
-rw-r--r-- 1 root root 0 2009-02-19 20:30 everybody_read
---------- 1 root root 0 2009-02-19 20:31 no_for_all
-rw------- 1 root root 0 2009-02-19 20:29 ordinary_file
-rw-r----- 1 root root 0 2009-02-19 20:27 others_can_also_read
----r----- 1 root root 0 2009-02-19 20:27 others_can_only_read
找到具有組讀權(quán)限的文件。使用下面的命令來(lái)找到當(dāng)前目錄下對(duì)同組用戶(hù)具有讀權(quán)限的文件,忽略該文件的其他權(quán)?。
find . -perm -g=r -type f -exec ls -l {} ;
-rw-r--r-- 1 root root 0 2009-02-19 20:30 ./everybody_read
-rwxrwxrwx 1 root root 0 2009-02-19 20:31 ./all_for_all
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read
-rw-r----- 1 root root 0 2009-02-19 20:27 ./others_can_also_read
找到對(duì)組用戶(hù)具有只讀權(quán)限的文件。
find . -perm g=r -type f -exec ls -l {} ;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read
找到對(duì)組用戶(hù)具有只讀權(quán)限的文件(使用八進(jìn)制權(quán)限形式)。
find . -perm 040 -type f -exec ls -l {} ;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read
會(huì)員登錄
賬號(hào)登錄還沒(méi)有賬號(hào)?立即注冊(cè)