admin管理员组文章数量:1609899
-perm mode 文件的权限正好是mode就匹配
-perm -mode 文件的权限包括mode就匹配(该文件还可以拥有额外的权限属性)
-perm +mode 文件的权限部分满足mode就匹配(已弃用,find新版使用-perm /mode)
例:创建四个文件,并测试
1 2 3 4 5 |
[root@localhost
test
]
#touch {1..4}
[root@localhost
test
]
#chmod 6000 1
[root@localhost
test
]
#chmod 2000 2
[root@localhost
test
]
#chmod 4000 3
[root@localhost
test
]
#chmod 6600 4
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@localhost
test
]
# find . -perm 6000 -ls
202028530 0 ---S--S--- 1 root root 0 Sep 22 17:31 .
/1
[root@localhost
test
]
# find . -perm -6000 -ls
202028530 0 ---S--S--- 1 root root 0 Sep 22 17:31 .
/1
202028533 0 -rwS--S--- 1 root root 0 Sep 22 17:31 .
/4
[root@localhost
test
]
# find . -perm +6000 -ls
find
: warning: you are using `-perm +MODE
'. The interpretation of `-perm +omode'
changed
in
findutils-4.5.11. The syntax `-perm +omode
' was removed in findutils-4.5.12, in favour of `-perm /omode'
.
202028530 0 ---S--S--- 1 root root 0 Sep 22 17:31 .
/1
[root@localhost
test
]
# find . -perm /6000 -ls
202028530 0 ---S--S--- 1 root root 0 Sep 22 17:31 .
/1
202028531 0 ------S--- 1 root root 0 Sep 22 17:31 .
/2
202028532 0 ---S------ 1 root root 0 Sep 22 17:31 .
/3
202028533 0 -rwS--S--- 1 root root 0 Sep 22 17:31 .
/4
|
网上看到的其他解释,结合看,理解更清晰:
-perm mode :搜尋檔案權限『剛好等於』 mode 的檔案,這個 mode 為類似 chmod
的屬性值,舉例來說, -rwsr-xr-x 的屬性為 4755 !
-perm -mode :搜尋檔案權限『必須要全部囊括 mode 的權限』的檔案,舉例來說,
我們要搜尋 -rwxr--r-- ,亦即 0744 的檔案,使用 -perm -0744,
當一個檔案的權限為 -rwsr-xr-x ,亦即 4755 時,也會被列出來,
因為 -rwsr-xr-x 的屬性已經囊括了 -rwxr--r-- 的屬性了。
-perm +mode :搜尋檔案權限『包含任一 mode 的權限』的檔案,舉例來說,我們搜尋
-rwxr-xr-x ,亦即 -perm +755 時,但一個檔案屬性為 -rw-------
也會被列出來,因為他有 -rw.... 的屬性存在!
本文转自 kuSorZ 51CTO博客,原文链接:http://blog.51cto/kusorz/1967840
版权声明:本文标题:find -perm详解 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1728576954a1164587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论