Linux ACLs Explained: Permissions Beyond chmod (setfacl and getfacl)
We have covered Linux file permissions: owner, group, others, and the chmod numbers that control them. That model works until it does not. What if two people need different access to the same file, but they are not in the same group? What if one contractor needs read access to one directory and nothing else? chmod cannot express that. Access Control Lists (ACLs) can.
The problem with chmod
Traditional permissions give you exactly three slots per file: what the owner can do, what one group can do, and what everyone else can do. The moment you need “Alice can read this, Bob can write it, and nobody else can touch it,” you are stuck — unless you start creating a new group for every combination, which quickly becomes unmanageable.
What ACLs add
An ACL is an extra list attached to a file, naming additional users and groups with their own permissions. The classic permissions still apply; ACL entries extend them. Most modern Linux filesystems (ext4, XFS, btrfs) support ACLs, and they are usually enabled by default.
Seeing ACLs with getfacl
getfacl project-report.txt
Typical output includes a line user:alice:r– which is the ACL entry: Alice gets read access even though she is not the owner and not in the group. The mask line caps the maximum permission any named user or group entry can grant.
Setting ACLs with setfacl
setfacl -m u:alice:r-- project-report.txtsetfacl -m g:auditors:r-x reports/setfacl -m d:u:bob:rw- shared/setfacl -m u:bob:rw- shared/
The -m flag modifies an entry. Prefix u: means a user, g: means a group, and d: marks a default entry that new files inside a directory inherit.
Removing ACLs
setfacl -x u:alice project-report.txtsetfacl -b project-report.txt
Always clean up ACLs when access is no longer needed. Forgotten ACL entries are a classic audit finding: someone who left the team still has access because nobody remembered the extra entry.
How ACLs interact with chmod
- The mask. When you run chmod on a file that has ACLs, it changes the mask, not the group permission. That can silently cap your named entries. After changing permissions, re-check with getfacl.
- The + in ls output. Run ls -l and a file with ACLs shows a + after the permission string, like -rw-r—–+. That plus sign is your signal that extra entries exist — always run getfacl before assuming you know who can access a file.
When to use ACLs
Use them when one file genuinely needs different access for different people — a shared report, a deploy key directory, a log folder an auditor needs to read. Do not use them as a replacement for good group design: if twenty people need the same access, a group is cleaner. And never use ACLs to paper over a broken ownership model — fix the owner and group first. Least privilege still rules: give each person the minimum access they need, nothing more, and audit the extras regularly with getfacl.



Comments
Post a Comment