Skip to content

Chapter 5 of 6

POSIX ACLs, Filesystem Attributes, and Capabilities

The classic user/group/other model is sufficient for many systems, but it cannot grant access to a fourth specific user without making the file world-readable. POSIX ACLs solve this. setfacl -m u:alice:r file grants Alice read access on a file, and multiple entries can be combined in a single invocation: setfacl -m u:alice:r,u:bob:rw,g:devops:rwx file. The matching query is getfacl file, which prints the full ACL alongside the traditional mode. ACLs may also define a default ACL on a directory — setfacl -d -m u:alice:rx dir — which automatically propagates to new files and subdirectories created inside. A web service such as www-data can therefore read a file owned by another user either when the file is world-readable, when www-data appears in the owning group, or when an ACL grants the access.

ACL administration follows the same backup discipline as any other configuration: getfacl -R / > acls.bak records every ACL under a tree, and setfacl --restore=acls.bak replays them. To strip all ACLs and return a file to the simple Unix model, setfacl -b file suffices. Some filesystems, notably FAT32, only support the eight bits of legacy DOS attributes, so POSIX ACLs cannot be stored natively there; mount options may simulate them, but this is always a shim rather than true ACL storage. Native Linux filesystems like btrfs and XFS do support POSIX ACLs alongside extended attributes, and XFS additionally exposes DMAPI metadata.

An entirely different way to extend privilege is through POSIX capabilities. Instead of giving an entire binary setuid root, the binary can be granted just the specific capability it needs. A common example is binding to a low port: setcap cap_net_bind_service=+ep /path/binary allows the program to listen on port 80 without the wider powers of root. The granted capabilities are queried with getcap binary. Together with SELinux and AppArmor MAC policies, capabilities form the modern alternatives to setuid and ACLs for fine-grained privilege control.

All chapters
  1. 1Reading and Converting Permission Modes
  2. 2Special Permission Bits and chmod Patterns
  3. 3Ownership, chown, and Recursive Patterns
  4. 4SSH, Immutable Files, and Sensitive Data
  5. 5POSIX ACLs, Filesystem Attributes, and Capabilities
  6. 6Diagnostics, Mounts, and Mandatory Access Control

Drill it

Reading is not remembering. These come from the Linux File Permissions And Chmod Patterns deck:

Q

What does <code>rwxr-xr--</code> mean?

Owner: rwx (7).Group: r-x (5).Other: r-- (4).Octal: 754.

Q

Convert <b>644</b> to symbolic.

rw-r--r-- — owner read+write, group read, others read.

Q

Convert <b>755</b> to symbolic.

rwxr-xr-x — typical for executables and directories.

Q

Convert <b>600</b> to symbolic.

rw------- — typical for private files like ~/.ssh/id_ed25519.