Linux · Systems fluency
How do chmod and chown work, and what are the risks?
Short answer
chmod changes permission bits using symbolic or octal notation, while chown changes ownership and group. Both require care because recursive changes can silently expose data or break running services.
Symbolic mode is readable and relative: u, g, o, and a select owner, group, other, or all; plus, minus, and equals add, remove, or set bits. Octal mode is compact and absolute, with each digit representing one triad.
chmod u=rw,g=r,o= app.conf
chmod 750 /srv/app
chown app:app /srv/app
chown -R app:app /srv/appRecursive changes need a target check
- Confirm the working directory and target path before using -R
- Avoid chown -R on / or on home directories containing unrelated data
- Remember that chown follows symlinks unless you pass -h
- Changing ownership needs root or the appropriate capability
- Prefer group ownership plus setgid for shared directories
Services often fail after a permission change because their user can no longer read a key or write a runtime directory. Check the service unit User, Group, and RuntimeDirectory settings before widening permissions.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between symbolic and octal chmod?
- 2Why can chown -R be dangerous?
- 3What happens when a service loses access to its runtime directory?
- 4When would you use setgid on a shared directory?
Say it in the interview
chmod changes the permission bits, either symbolically or with octal digits. chown changes the owner and group. I check the exact path and user before using recursive flags, because a broad chown can expose secrets or break services. For shared directories I prefer group ownership with setgid and a sensible umask rather than making everything world-writable.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Linux mock interview and get scored feedback on depth, clarity and confidence.