Ownership and group changes
Quick answer
chown changes the owner and optionally group; chgrp changes the group. In ordinary Linux operation, changing ownership to another user requires appropriate privilege. An owner can normally change the group to one they belong to.
Prepare the practice environment
Use the chapter fixture described in lab-fixtures/permissions/README.md. Run setup as a normal user in a disposable Linux environment, enter the printed directory, check pwd, and run export LC_ALL=C; umask 022. Every example assumes a fresh fixture. Commands omit the terminal prompt; outputs below are not commands.
How it works
The syntax is chown OWNER[:GROUP] FILE or chgrp GROUP FILE. A name or numeric ID can identify the account. The process must have authority; ownership changes may clear special permission bits and may affect service access. Use id, stat and a narrowly scoped path before changing anything. The examples below only retain your existing owner or primary group; they are not demonstrations of privileged transfer. In a disposable VM, an administrator could assign a dedicated service account and group after verifying that account exists and the path is intended. Never use your real system directories for such a lab.
Ownership answers who a file belongs to; mode bits answer what each ordinary access class may do. Changing a group does not automatically add group read permission. A successful same-owner operation in the example does not prove that the caller can transfer ownership to another UID. Compare numeric IDs before and after a narrowly scoped change, and verify intended access independently.
Try the examples
test "$(stat -c %g report.txt)" = "$(id -g)" && printf "primary-group\n"The fixture has the current primary group; group names may differ across systems.
Expected stdout:
primary-groupchown "$(id -u)" report.txttest "$(stat -c %u report.txt)" = "$(id -u)" && printf "owner retained\n"No ownership transfer or elevated privileges are requested.
Expected stdout:
owner retainedchgrp "$(id -g)" report.txttest "$(stat -c %g report.txt)" = "$(id -g)" && printf "group retained\n"A same-group operation demonstrates syntax and verification without creating accounts.
Expected stdout:
group retainedCommon mistakes
Do not use recursive chown on system trees or follow unreviewed symlinks. Do not use sudo simply because chown fails. Determine the intended service identity first.
Practice
Explain the difference between chown and chgrp and verify the current owner and group of report.txt. Describe what would be needed for transfer to another account, without attempting it.
Related references
Study: chown, chgrp. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Ownership and group changes — Knowledge Check
Apply the lesson concepts to the controlled permission fixture.
Which command changes only the owning group?
What does chown alice:team report.txt request?
Can an ordinary owner normally transfer ownership to another UID?
Why inspect after chown?