Keep notes.txt's owner and change its owning group to writers.
Which direct command is appropriate?
chgrp GROUP FILE changes the owning group while preserving the file owner. A regular user is normally limited to groups they belong to.
Detailed explanation
chmod writers notes.txtIncorrect. chmod changes permissions, not ownership.
Incorrect. chmod changes permissions, not ownership.
chown writers notes.txtIncorrect. chown writers notes.txt treats writers as the owner.
Incorrect. chown writers notes.txt treats writers as the owner.
chgrp writers notes.txtCorrect. chgrp writers notes.txt changes only the owning group.
Correct. chgrp writers notes.txt changes only the owning group.
groups writers notes.txtIncorrect. groups displays memberships rather than changing file ownership.
Incorrect. groups displays memberships rather than changing file ownership.
Try it yourself
An example you can run in a temporary verification environment.
chgrp --help | sed -n '1,3p'Expected result
chgrpの使用法。実ファイルのグループは変更しないKey points
- chgrp changes group owner
- File owner stays
- Group eligibility is restricted
Notes
- Environment: GNU coreutils 9.x / helpのみ
- 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.