Access control lists

Intermediate · 1 min

POSIX ACLs for when owner, group and other are not enough: getfacl and setfacl, the mask that quietly limits them, default ACLs, and when a group is simpler.

Before thisSpecial permission bits and umask

Red Hat Enterprise Linux · 28 min · from 28:32

Access control lists

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Red Hat Enterprise LinuxReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A POSIX ACL adds entries for named users and named groups on top of the owner, group and other bits. ls -l marks such files with a + after the mode.
  • setfacl -m u:bob:rw file adds an entry, -x removes one, -b removes all extended entries. getfacl shows the full list, including #effective: notes where the mask cuts rights.
  • The mask entry caps every named user, named group and the owning group. Once a file has an ACL, the group bits shown by ls and changed by chmod are the mask, so chmod g-w silently takes write away from every named entry.
  • A default ACL on a directory (setfacl -d -m ...) is copied to new files and subdirectories created inside it, and the umask is ignored there. Existing files are not changed; use -R for those.
  • Prefer a group plus a setgid directory when one team needs access. Reach for ACLs when access really is per person or crosses teams, such as one auditor or one service account.

When one group is not enough

The permission bits allow one owner, one group and everyone else. Usually that is enough, especially with the setgid directory trick from the previous lesson. Then real life arrives. The devs group owns /srv/app, but one auditor from another team needs read access to the logs, and the backup service account needs to read everything. You could create a new group for each combination of people, and soon have dozens of groups nobody understands.

Access control lists solve this by letting a file carry extra entries: this named user gets these rights, that named group gets those. The acl(5) man page describes them as a way “to define more fine-grained discretionary access rights for files and directories”. Linux implements the POSIX draft standard ACLs on ext4, XFS, Btrfs and most other native filesystems. ext4(5) lists acl and noacl as mount options.

Reading an ACL

getfacl prints the whole list. This sample is from the getfacl(1) man page:

# file: somedir/
# owner: lisa
# group: staff
user::rwx
user:joe:rwx               #effective:r-x
group::rwx                 #effective:r-x
group:cool:r-x
mask::r-x
other::r-x
default:user::rwx
default:user:joe:rwx       #effective:r-x
...

user::, group:: and other:: are the ordinary owner, group and other bits. user:joe: and group:cool: are the named entries an ACL adds. mask:: is the entry that trips people up. The default: lines are the default ACL, covered below. In ls -l, a file with extended entries shows a + after its mode.

Changing an ACL

setfacl modifies entries. From its man page’s examples and options, not run here, since this Mac uses a different ACL system:

setfacl -m u:auditor:r  /srv/app/logs/app.log     # add or change a named user
setfacl -m g:backup:rx  /srv/app                   # a named group
setfacl -x u:auditor    /srv/app/logs/app.log      # remove one entry
setfacl -b              /srv/app/logs/app.log      # remove all extended entries
setfacl -R -m u:auditor:rX /srv/app/logs           # recursive; X = execute only on dirs

The mask

The acl(5) man page defines the mask as “the maximum access rights that can be granted by entries of type ACL_USER, ACL_GROUP_OBJ, or ACL_GROUP”. It caps every named user, every named group, and the owning group. Only the owner and other escape it. That is what the #effective: comments in getfacl output show: joe has rwx in his entry but gets only r-x.

Why have it? So that the old chmod tools still mean something on a file with an ACL. The man page explains: “If the ACL has an ACL_MASK entry, the group permissions correspond to the permissions of the ACL_MASK entry.” Once a file has an ACL, the group bits in ls -l are the mask, and chmod g-w lowers the mask.

That produces a classic surprise. I wrote a few lines of Python that follow the man page’s access check algorithm step by step. It is my own stand-in, not the kernel. The file is owned by alice, group devs with r, plus user:bob:rw and group:qa:rw:

mask::rw                           bob write=True  carol(qa) write=True  dave(devs) write=False
after chmod g-w (mask::r)          bob write=False carol(qa) write=False dave(devs) write=False

One chmod that looked like it only touched the group took write access from bob and the whole qa group. setfacl normally recalculates the mask for you: per its man page, the mask is “set to the union of all permissions of the owning group, and all named user and group entries” unless you pass -n or set the mask yourself. Plain chmod does not.

Default ACLs and inheritance

An ACL on a directory governs only the directory. To make new files inherit entries, give the directory a default ACL:

setfacl -d -m g:backup:rX /srv/app

acl(5) says a new object “inherits the default ACL of the containing directory as its access ACL”, trimmed by the mode the creating program asked for. And umask(2) notes that in this case “the umask is ignored”. Default ACLs do not change files that already exist, so combine -R for the current contents with -d for future ones. They also do not follow files that are moved in with mv from elsewhere on the same filesystem, because a move keeps the file’s existing ACL.

ACLs or groups?

ACLs are powerful and easy to lose track of. They are invisible in a normal listing apart from the +. Backups and copies drop them unless told otherwise: GNU cp -a preserves them because -a means --preserve=all, and tar needs its --acls option. And every exception is another thing to audit.

So use a group, a setgid directory and a 002 umask when access maps onto one team. Use ACLs when it does not: a single auditor, a service account that needs to read one tree, or two teams sharing one directory with different rights.

About the video

The embed is Red Hat’s “Linux Permissions and ACLs | Into the Terminal 185”, a live stream from May 2026, clipped to its ACL half (about 28 minutes). It runs from a web-server example of why ACLs matter, through getfacl and setfacl basics, granting and removing entries for several users and groups, default ACLs, setgid versus default group ACLs, and the -R, -m and -d flags. That matches this lesson’s scope closely, with stream pacing. I judged it from the chapters and description, and English from the original English audio track. The first half of the stream covers basic permissions and umask, which shell-bash and the previous lesson cover. The Technology Sandbox’s twenty-minute walkthrough in deeper is the runner-up.

What was run: only my Python stand-in for the access check, on a Mac. The getfacl sample is copied from its man page, and the rules are quoted from acl(5), setfacl(1), getfacl(1), umask(2), ext4(5) and cp(1), checked 2026-11-28, along with the GNU tar manual’s section on --acls.

Check yourself

  1. 01You granted bob rw with setfacl, then someone ran chmod 640 on the file. Bob can now only read. Why?

    On a file with an ACL, the group permission bits are the mask. chmod 640 set the mask to r--, and the mask caps named user entries, so bob's effective rights became read-only.

  2. 02You set an ACL on a project directory, but files created inside afterwards do not get it. What was missing?

    A default ACL. Access ACLs apply only to the object itself; setfacl -d -m sets the default ACL that new files and subdirectories inherit.

  3. 03How do you see that a file has extended ACL entries without running getfacl?

    ls -l shows a + after the permission string, for example -rw-rw-r--+.

  4. 04When is a plain group a better choice than ACLs?

    When everyone who needs access belongs to one team. A group with a setgid directory and a 002 umask is simpler to audit, survives tools that drop ACLs, and is visible in ls -l.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark