102-500 · Question #94
Which of the following commands finds all files owned by root that have the SetUID bit set?
The correct answer is A. find / -user root -perm -4000. Option A is correct because find / -user root properly filters files by owner using the -user flag (accepting either a username or numeric UID), and -perm -4000 correctly tests for the SetUID bit - the leading - means "at least these bits are set," and 4000 is the octal…
Question
Options
- Afind / -user root -perm -4000
- Bfind / -user 0 -mode +s
- Cfind / -owner root -setuid
- Dfind / -owner 0 -permbits 0x100000000
- Efind / --filter uid=1 --filter pers=u+s
How the community answered
(41 responses)- A76% (31)
- B7% (3)
- C2% (1)
- D2% (1)
- E12% (5)
Explanation
Option A is correct because find / -user root properly filters files by owner using the -user flag (accepting either a username or numeric UID), and -perm -4000 correctly tests for the SetUID bit - the leading - means "at least these bits are set," and 4000 is the octal representation of the SetUID bit.
Why the distractors fail:
- B (
-mode +s):-modeis not a validfindpredicate; the correct flag is-perm. The+modesyntax forfindwas also deprecated and removed in modern versions. - C (
-owner root -setuid):-ownerdoes not exist infind; the correct flag is-user.-setuidis also fabricated - no such predicate exists. - D (
-owner 0 -permbits 0x100000000): Same-ownererror, and-permbitswith a hex argument is entirely invented syntax. - E (
--filter uid=1 --filter pers=u+s):finduses single-dash predicates, not--filterflags; this syntax belongs to no real tool.
Memory tip: Think of -perm -4000 as "4 is for SetUID" - the leading 4 in the octal permission string always signals the SetUID bit, just as you see in chmod 4755. The - prefix on -4000 means "this bit must be at minimum set," which handles files with additional permissions too.
Topics
Community Discussion
No community discussion yet for this question.