As administrator, change report.txt's owner to alice while keeping its group.
Which command is appropriate?
chown OWNER FILE changes only the owner when the group component is omitted. Use OWNER:GROUP to change both.
Detailed explanation
chgrp alice report.txtIncorrect. chgrp changes the group.
chmod alice report.txtIncorrect. chmod changes mode bits.
chown :alice report.txtIncorrect. chown :alice changes the group to alice.
chown alice report.txtCorrect. chown alice report.txt changes only the owner.
Try it yourself
An example you can run in a temporary verification environment.
chown --help | sed -n '1,3p'Expected result
chownの使用法。実ファイルの所有者は変更しないKey points
- chown changes owner
- Omitting group preserves it
- Appropriate privileges are required
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
A chown specification containing only an owner changes that field while leaving the group unspecified.
Check the side effect
Verify the current owner and group before applying an ownership change that may require privilege.