centos 如何 根據文件權限查找文件
下面的操作時合理的:
找到具有指定權限的文件
忽略其他權限位,檢查是否和指定權限匹配
根據給定的八進制/符號表達的權限搜索
此例中,假設目錄包含以下文件。注意這些文件的權限不同。
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
找到具有組讀權限的文件。使用下面的命令來找到當前目錄下對同組用戶具有讀權限的文件,忽略該文件的其他權?。
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
找到對組用戶具有只讀權限的文件。
find . -perm g=r -type f -exec ls -l {} ;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read
找到對組用戶具有只讀權限的文件(使用八進制權限形式)。
find . -perm 040 -type f -exec ls -l {} ;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read