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.
chown writers notes.txtIncorrect. chown writers notes.txt treats writers as the owner.
chgrp writers notes.txtCorrect. chgrp writers notes.txt changes only the owning group.
groups writers notes.txtIncorrect. 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のみ
- Use a disposable file or directory when checking chmod calculations.
- Exact permission display can vary slightly with filesystem and distribution defaults.
Foundation review
Place the operation
Ownership commands and permission commands modify different metadata; a group-membership query modifies neither.
Check the side effect
Confirm whether the requirement names an owner, a group owner, or a permission bit before choosing a command.