List regular files under /usr/local/bin with either SUID or SGID set.
Other permission bits are not part of the condition.
Which command is appropriate?
GNU find -perm /6000 matches files with at least one of SUID 4000 or SGID 2000 set.
Detailed explanation
find /usr/local/bin -type f -perm /6000Correct. /6000 matches either the SUID or SGID bit.
Correct. /6000 matches either the SUID or SGID bit.
find /usr/local/bin -type f -perm -6000Incorrect. -6000 requires both bits.
Incorrect. -6000 requires both bits.
find /usr/local/bin -type f -perm 6000Incorrect. A bare mode is an exact permission match.
Incorrect. A bare mode is an exact permission match.
find /usr/local/bin -type f -perm /0600Incorrect. 0600 selects owner read/write bits, not special bits.
Incorrect. 0600 selects owner read/write bits, not special bits.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/suid" "$tmp/sgid" "$tmp/plain"; chmod 4755 "$tmp/suid"; chmod 2755 "$tmp/sgid"; find "$tmp" -type f -perm /6000 -printf '%f
' | sort; rm -rf "$tmp"Expected result
sgid
suidKey points
- SUID is 4000
- SGID is 2000
- /MODE means any bit
Notes
- Environment: GNU findutils 4.9 / 一時ディレクトリ
- 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.