Add set-user-ID to tool while preserving its existing ordinary permissions.
Which command is appropriate?
Symbolic u+s adds SUID. g+s is SGID, o+t is sticky, and + preserves existing ordinary permissions.
Detailed explanation
chmod g+s toolIncorrect. g+s sets set-group-ID.
Incorrect. g+s sets set-group-ID.
chmod o+t toolIncorrect. o+t sets the sticky bit.
Incorrect. o+t sets the sticky bit.
chmod u+x toolIncorrect. u+x adds execute permission, not SUID.
Incorrect. u+x adds execute permission, not SUID.
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.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); chmod 755 "$tmp"; chmod u+s "$tmp"; stat -c '%A %a' "$tmp"; rm -f "$tmp"Expected result
-rwsr-xr-x 4755Key points
- u+s is SUID
- g+s is SGID
- + adds
Notes
- Environment: GNU coreutils 9.x / 空の一時ファイルを表示のみ
- 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.