ACLs in brief: rights for named people
Video 119 of 140 in Virtualization Foundations, in the unit “Users, groups, permissions and sudo”. 2:47, with English and Hindi audio.
The usual Linux rights name one owner and one group. Sometimes a single colleague from another team needs access to one file, and the usual model cannot express that neatly. An access control list, or ACL, solves this by adding an extra entry for one named user or group. This article explains the usual model and where it is too coarse, how to add and read an ACL entry with setfacl and getfacl, and what to check before you depend on one.
What you will learn
- A usual file has one owner and one group, so one colleague from another team cannot be added neatly.
- An ACL adds extra entries, and each entry names one user or one group with its own rights.
- setfacl with the m option adds an entry, and getfacl prints the full list.
- The mask line limits the most that named entries and the group may do.
- Keep ACL entries few, because a long list is hard to audit.
Where the usual rights are too coarse
With the usual rights, a file has one owner, one group, and everyone else. Making a colleague from another team a co-owner is not possible. Consider an auditor from finance who must read one report, but must not see the whole team's folder. Adding that person to the team's group would give them every file that group can reach, which is too much.
An access control list adds extra entries to the file. Each entry names one user or one group, and gives it its own rights, without changing the owner or the group.
Giving one person read and write
setfacl -m u:bob:rw report.csvThe m option adds an entry. Here user bob gets read and write, and nothing else about the file changes. To remove one entry later, use setfacl with the x option and the user name. The owner, the group and the other rights stay as they were.
Reading the full list
getfacl report.csvThe lines with a user name or a group name are the extra entries. The mask line limits what those entries may do. If the mask is too low, a named entry gives less than it says. Plain ls shows a plus sign after the mode when a file has extra ACL entries, so you can spot them quickly.
What to check before you depend on an ACL
The ACL tools come from the acl package, and the file system must support ACLs. Check both before you rely on an entry. Keep the list short, because one exception is easy to explain, while a long list of entries is hard to audit.
Try it yourself
You need a practice file that you own, and an account named bob on the machine. Adding an entry changes who can open the file, so use a file that does not matter.
Give bob read and write on this one file. The owner and the group stay the same.
setfacl -m u:bob:rw report.csvPrint the full list, and look for the entry that names bob.
getfacl report.csvWhat you should see: The list shows the owner, the group, the mask, and an entry for user bob with read and write.
Terms
- ACL
- An access control list: extra entries on a file that give rights to named users or groups, on top of the usual rights.
- Mask
- The ACL line that sets the most that named entries and the group may do on the file.
Check yourself
Why not add a colleague to the group instead of using an ACL?
The group would give that person every file the group can reach. An ACL entry gives rights to one named user on one file.
What does the mask line do?
It sets the most that named entries and the group may do. If it is too low, a named entry gives less than it says.
How can you tell in a plain ls listing that a file has ACL entries?
A plus sign appears after the mode when the file has extra ACL entries.
Previous: System users: accounts that run services. Next: Diagnosing permission denied.