Linux · Systems fluency
How do Linux file permissions work?
Short answer
Every file has an owner, a group, and permission bits for read, write, and execute. Directories need execute permission to be traversed, and special bits add setuid, setgid, or sticky behavior.
Permission checks use the process effective user and group IDs. The owner bits apply first, then group bits, then other bits. Root bypasses most checks, which is why testing as root hides permission bugs.
ls -l /etc/shadow
chmod 640 app.conf
chmod u+x deploy.shReading the triad
- Read on a file: view contents; on a directory: list names
- Write on a file: modify contents; on a directory: create or remove entries
- Execute on a file: run it; on a directory: traverse into it
- setuid runs an executable as its owner; setgid inherits the group or directory group
- sticky on a shared directory prevents users from deleting other users files
Access control lists add per-user and per-group rules beyond the basic nine bits. POSIX ACLs are useful when a shared directory needs several distinct teams without widening the group to everyone.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What does execute permission mean on a directory?
- 2How do setuid and setgid differ?
- 3What is a sticky bit used for?
- 4When would you use an ACL instead of changing the group?
Say it in the interview
Each file has owner, group, and other permission triads for read, write, and execute. The kernel checks the owner first, then group, then other. On directories, execute means traverse and write means create or remove entries, while special bits add setuid, setgid, or sticky behavior. I use ACLs when a simple owner and group model is not expressive enough.
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.