201-450 · Question #181
What does the following script do? #!/bin/bash find / -perm +4000 | mail -s "Daily find output" root
The correct answer is D. Emails a report of all suid files to root. Option D is correct because -perm +4000 searches for files with the SUID (Set User ID) bit set - the 4 in the octal 4000 mask represents this bit, which allows executables to run with the file owner's privileges (often root) rather than the invoking user's privileges. The…
Question
Options
- AEmails a report of all guid files to root
- BEmails a report of all important files to root
- CEmails a report of all writeable files to root
- DEmails a report of all suid files to root
- ECorrects permissions on files and emails the result to root
How the community answered
(29 responses)- A3% (1)
- B3% (1)
- C10% (3)
- D83% (24)
Explanation
Option D is correct because -perm +4000 searches for files with the SUID (Set User ID) bit set - the 4 in the octal 4000 mask represents this bit, which allows executables to run with the file owner's privileges (often root) rather than the invoking user's privileges. The result is piped to mail, which sends it as an email with the subject "Daily find output" to root. Option A is wrong because GUID/SGID files use the 2000 bitmask, not 4000. Options B and C are wrong because "important" and "writable" files have no corresponding single permission bit - writable files would use -perm -002 or similar. Option E is wrong because find with -perm only locates files; it never modifies permissions (you'd need -exec chmod for that).
Memory tip: Think "4 = SUID, 2 = SGID, 1 = Sticky" - the leading digit in a 4-octet permission like 4755 always reveals the special bit. Seeing 4000 in a find command should immediately signal "SUID hunt."
Topics
Community Discussion
No community discussion yet for this question.