Add the set-user-ID bit to the root-owned binary tool.
Preserve its existing ordinary permissions.
Which command is appropriate?
Symbolic u+s adds the set-user-ID bit. A setuid executable can cross a privilege boundary, so its code and ownership must be tightly controlled.
Detailed explanation
chmod g+s toolIncorrect. g+s sets setgid, not setuid.
Incorrect. g+s sets setgid, not setuid.
chmod u+x toolIncorrect. u+x adds execute permission rather than setuid.
Incorrect. u+x adds execute permission rather than setuid.
chmod u+s toolCorrect. chmod u+s tool adds the set-user-ID bit.
Correct. chmod u+s tool adds the set-user-ID bit.
chmod +t toolIncorrect. +t sets the sticky bit.
Incorrect. +t sets the sticky bit.
Try it yourself
An example you can run in a temporary verification environment.
chmod --helpExpected result
MODEではsをset-user-IDまたはset-group-IDに使用できるKey points
- u+s means setuid
- Ordinary permissions remain
- Review the privilege boundary
Notes
- Environment: GNU coreutils 9.x/Linux
- 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.