101-400 · Question #447
Which of the following commands enables the setuid (suid) permission on the executable /bin/foo?
The correct answer is B. chmod 4755 /bin/foo. See the full explanation below for the reasoning.
Question
Options
- Achmod 1755 /bin/foo
- Bchmod 4755 /bin/foo
- Cchmod u-s /bin/foo
- Dchmod 755+s /bin/foo
How the community answered
(24 responses)- A8% (2)
- B83% (20)
- C4% (1)
- D4% (1)
Community Discussion
3B is your answer. The leading 4 in octal mode sets the setuid bit, so chmod 4755 /bin/foo gives the file setuid plus the usual rwxr-xr-x permissions, which is exactly what you need when you want the executable to run as its owner rather than the calling user, same as passwd does in the real world.
B is right. The leading 4 in the four-digit octal representation sets the setuid bit, so 4755 means setuid on, rwxr-xr-x underneath. C is the trap, because u-s actually removes setuid, which is the opposite of what the question asks, and people who half-remember symbolic mode syntax will burn themselves on that one.
B is right, 4 sets the suid bit, not 1 (that's sticky).