Under /usr, list regular files whose owner-execute position has the SUID bit set.
Suppress permission-denied messages.
Which command is appropriate?
find -type f -perm -4000 finds regular files containing the SUID bit; the leading hyphen means all specified bits must be present.
Detailed explanation
find /usr -type f -perm -4000 2>/dev/nullCorrect. It searches regular files with SUID and redirects standard errors.
Correct. It searches regular files with SUID and redirects standard errors.
find /usr -type d -perm -4000 2>/dev/nullIncorrect. It limits the search to directories.
Incorrect. It limits the search to directories.
find /usr -type f -perm -2000 2>/dev/nullIncorrect. 2000 searches for SGID rather than SUID.
Incorrect. 2000 searches for SGID rather than SUID.
find /usr -type f -perm 4000 2>/dev/nullIncorrect. Exact mode matching would miss SUID files that also have ordinary permission bits.
Incorrect. Exact mode matching would miss SUID files that also have ordinary permission bits.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-type f=regular files' '-perm -4000=SUID bit present' '2>/dev/null=discard diagnostics'Expected result
-type f=regular files
-perm -4000=SUID bit present
2>/dev/null=discard diagnosticsKey points
- SUID is octal 4000
- -perm -MODE means contains the bits
- Limit to regular files
Notes
- Environment: GNU findutilsの構文対応表(filesystem走査なし)
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.