Keep script.sh's existing permissions and add execute permission only for its owner.
Do not change group or other permissions.
Which command is appropriate?
In symbolic chmod notation, u selects the owner, + adds a permission, and x means execute. Existing permissions remain.
Detailed explanation
chmod u+x script.shCorrect. chmod u+x script.sh adds execute permission for the owner only.
Correct. chmod u+x script.sh adds execute permission for the owner only.
chmod a+x script.shIncorrect. a selects all classes, including group and others.
Incorrect. a selects all classes, including group and others.
chmod u=x script.shIncorrect. u=x replaces the owner's permission set rather than adding execute.
Incorrect. u=x replaces the owner's permission set rather than adding execute.
chmod g+x script.shIncorrect. g selects the group, not the owner.
Incorrect. g selects the group, not the owner.
Try it yourself
An example you can run in a temporary verification environment.
chmod --helpExpected result
MODEによってファイルモードを変更する使用法Key points
- u is the owner
- + adds
- x is execute
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.