Ownership, groups, and umask
Separate who owns a file from what permissions allow.
chown user:group
20 min read, 25 min lab
foundation
Ownership answers who the user and group owners are. Mode bits answer what each class can do. `umask` sets default permissions for newly created files and directories by subtracting permissions.
A service account owns config, but a deployment group needs read access.
Worked command
$ stat app.conf$ umask0022$ chown app:deploy app.conf$ chmod 640 app.conf
Do not recursively chown a tree until you know exactly which paths and service users are involved.
State the owner, group, intended readers, and intended writers before changing access.
app.conf is mode 640 and a deploy engineer still gets 'Permission denied' reading it. What is the most likely cause?
Show the answer
Correct: A. The engineer is not the owner and not in the file's group, so they fall to 'other' (---)
Mode is correct but it is evaluated against the file's owner and group; a user outside both lands in the 'other' class, which 640 gives no access. Jumping to 777 'fixes' it by removing the boundary entirely instead of adding the engineer to the group.
Practice checklist
- Create test files.
- Compare owner/group/mode with `stat`.
- Write a planned owner/group/mode change before applying it.
Deliverable evidence
- A permission repair plan.
- Before/after owner, group, and mode.
shows: How a file's access splits into ownership (who) and mode bits (what) per user/group/other class, how umask seeds defaults, and where sudo crosses the boundary.
does not prove: It shows the model, not your case: only running ls -l, stat, id, and sudo -l on the actual file proves who you are and what access you currently hold.
Commit these to memory, then drill them until recall is automatic.
cue Owner keeps the file, but a deploy group needs read-only access; set group ownership and a group-readable mode.
show recall target
chown app:deploy app.conf && chmod 640 app.conf