Recursively process project and add group read permission.
Add execute/search permission to directories and files that already have an execute bit, but do not make ordinary documents executable.
Which command is appropriate?
GNU chmod X adds execute/search permission only to directories or files that already have an execute bit. With -R it applies recursively.
Detailed explanation
chmod -R g+rx projectIncorrect. g+rx gives execute permission to every file, including ordinary documents.
Incorrect. g+rx gives execute permission to every file, including ordinary documents.
chmod g+rX projectIncorrect. Without -R it affects only the top-level project directory.
Incorrect. Without -R it affects only the top-level project directory.
chmod -R g+r projectIncorrect. g+r adds read permission but no conditional search permission.
Incorrect. g+r adds read permission but no conditional search permission.
chmod -R g+rX projectCorrect. chmod -R g+rX project adds group read and conditional execute/search permission.
Correct. chmod -R g+rX project adds group read and conditional execute/search permission.
Try it yourself
An example you can run in a temporary verification environment.
chmod --helpExpected result
-Rによる再帰処理。Xの詳細はchmod(1)で確認するKey points
- X is conditional execute
- Directories need search permission
- -R is recursive
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.