[英]How to grep for all the files in a directory that do not have a set of file extensions?
[英]Find all files that have set UID bit on
我正在嘗試查找具有“SUID”權限的所有文件並將其寫入文本文件,但是當我運行以下命令時,文本文件為空:
sudo find / -perm 4000 > suid.txt
我的命令有問題嗎?
正確的語法是:
sudo find / -perm -4000 > suid.txt
要么
sudo find / -perm -u+s > suid.txt
例如:
sudo find / -perm -4000 -exec ls -l {} +
給出這個輸出:
-rwsr-xr-x 1 root root 30800 May 15 2015 /bin/fusermount
-rwsr-xr-x 1 root root 94792 Sep 2 2015 /bin/mount
-rwsr-xr-x 1 root root 44168 May 7 2014 /bin/ping
-rwsr-xr-x 1 root root 44680 May 7 2014 /bin/ping6
-rwsr-xr-x 1 root root 36936 Jan 27 2016 /bin/su
<truncated>
你的命令的問題是它正在尋找設置set uid位而沒有設置其他設置的模式位。 添加-
前綴將查找設置了set uid的所有模式,而不管其他位。
從man find
:
- 精子模式
文件的權限位是精確模式(八進制或符號)。 由於需要完全匹配,如果要將此表單用於符號模式,則可能必須指定相當復雜的模式字符串。 例如,-perm g = w將僅匹配具有模式0020的文件(即,組寫入權限是唯一的權限集)。 您更有可能想要使用
/' or
- '表單,例如-perm -g = w,它匹配具有組寫權限的任何文件。-perm -mode
為文件設置了所有權限位模式。 這種形式接受符號模式,這通常是想要使用它們的方式。 如果使用符號模式
u',
必須指定u',
g'或“o”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.