getfacl is the Linux command-line utility that displays the POSIX access control lists (ACLs) of files and directories, listing the owner, owning group, others, any named user and group entries, the mask and, for directories, the default ACL. Its companion setfacl modifies those lists, and the two together are the standard tools for managing permissions on Linux beyond the classic owner, group and other model.
Both commands come from the `acl` package and work on filesystems that support extended ACLs, including ext4, XFS, Btrfs and tmpfs. Where ls -l shows only nine permission bits, getfacl reveals the full set of rules the kernel actually evaluates.
How getfacl reads and presents an ACL
getfacl retrieves ACL data from the extended attribute `system.posix_acl_access` and, for directories, system.posix_acl_default, then prints it in a standard text format that setfacl can read back. A typical output begins with three comment lines naming the file, owner and group, followed by one entry per line.
Each entry has the form type:qualifier:permissions, for example user:alice:rw- or group:devs:r-x. When the effective rights of an entry are narrower than its listed rights because of the mask, getfacl appends a comment such as #effective:r--.
| Entry | Meaning | Affected by mask |
|---|---|---|
| user:: | Permissions of the file owner | No |
| user:name: | Named user entry for a specific account | Yes |
| group:: | Permissions of the owning group | Yes |
| group:name: | Named group entry for a specific group | Yes |
| mask:: | Upper limit for group-class entries | Not applicable |
| other:: | Everyone not matched by another entry | No |
| default: | Template inherited by new files in a directory | Applies to children |
A file whose ACL contains only the three base entries has a minimal ACL equivalent to its mode bits. As soon as a named entry exists, ls -l shows a plus sign after the permission string, which is the cue to run getfacl.
Useful getfacl and setfacl options
getfacl and setfacl share a small, consistent set of options that cover inspection, modification, recursion and backup. The most practical ones are summarized below.
| Command and option | Action | Example |
|---|---|---|
| getfacl -R | Lists ACLs recursively | getfacl -R /srv/share |
| getfacl -d | Shows only the default ACL | getfacl -d /srv/share |
| getfacl -c | Omits the comment header | getfacl -c report.txt |
| getfacl -p | Keeps absolute paths in output | getfacl -pR /data |
| setfacl -m | Adds or modifies entries | setfacl -m u:alice:rw file |
| setfacl -x | Removes specific entries | setfacl -x g:temp file |
| setfacl -b | Removes all extended entries | setfacl -b file |
| setfacl –restore | Applies a saved getfacl dump | setfacl --restore=acl.txt |
A reliable backup and restore pattern is getfacl -R -p /data > acl.txt followed later by setfacl --restore=acl.txt. This preserves permissions when files are copied with tools that do not carry ACLs, and it serves as an audit snapshot before large permission changes.
getfacl compared with other permission tools
getfacl answers the question who can access this file and how, which overlaps with several neighboring tools that each show or change only part of the picture. Choosing the right one avoids misreading permissions.
| Tool | What it shows or changes | Limitation |
|---|---|---|
| ls -l | Mode bits and a plus sign for ACLs | Hides named entries |
| stat | Mode, owner, group and timestamps | Does not list ACL entries |
| chmod | Changes mode bits | On ACL files, group bits change the mask |
| getfacl | Full POSIX ACL including defaults | Read-only; no modification |
| setfacl | Adds, edits or removes ACL entries | Requires filesystem ACL support |
| lsattr | Filesystem attributes such as immutable | Unrelated to ACL entries |
The interaction with chmod is a frequent source of confusion. On a file with an extended ACL, the group permission bits shown by `ls -l` represent the mask, not the owning group, so chmod g-w silently removes write access from every named user and group entry.
Default ACLs and permission inheritance
A default ACL is set only on directories and acts as a template for new files and subdirectories created inside them. getfacl displays these entries with the default: prefix, and setfacl creates them with the -d option, for example setfacl -d -m g:devs:rwx /srv/project.
New files receive the default ACL as their access ACL, but the creating program’s requested mode still limits the result, so a file created with mode 0644 will not gain execute rights from the default. When a default ACL exists, the process umask is ignored for that directory, which makes default ACLs the preferred way to keep a shared folder group-writable.
- New subdirectories inherit both the access and the default ACL, so the rule propagates down the tree.
- Existing files are not changed by adding a default ACL; apply
setfacl -R -mseparately. - Moving files with `mv` within one filesystem keeps their original ACL rather than adopting the new parent’s default.
Limitations and common mistakes
The main practical limitation is that ACLs are not preserved by every tool or filesystem. A copy with cp without -a or --preserve=all, an archive made with tar lacking --acls, or a transfer with rsync lacking -A drops the extended entries without warning.
| Symptom | Cause revealed by getfacl | Fix |
|---|---|---|
| Named user cannot write despite rw entry | Restrictive mask limits effective rights | Raise mask with setfacl -m m::rw |
| New files lack shared group access | No default ACL on parent directory | Add one with setfacl -d -m |
| Permissions vanished after copy | Extended entries missing | Restore from a getfacl dump |
setfacl returns operation not supported | Filesystem mounted without ACL support | Check mount options or filesystem type |
Note also that NFSv4 ACLs use a different model with allow and deny entries; on such mounts getfacl may show only an approximation, and the nfs4_getfacl utility is needed for an accurate view.
Put simply
Standard Linux permissions resemble a guest list with only three lines: the owner, a single group and everyone else. Sometimes that is not enough, for example when two different teams need different access to the same folder. Access control lists add extra named lines for specific people or groups.
getfacl is the command that prints the whole guest list for a file or folder, and setfacl is the command that adds or crosses out names on it. If access behaves strangely, getfacl is usually the first place to look.
In practice
A university research lab stores data in /srv/lab on an Ubuntu server. The owning group is researchers, but an external auditor account named audit1 needs read-only access, and the analysts group needs read and write access without joining the main group. The administrator runs setfacl -R -m u:audit1:rX,g:analysts:rwX /srv/lab and adds matching default entries so new files inherit the same rules.
A week later, analysts report they cannot save files. Running getfacl on one directory shows mask::r-x with the comment #effective:r-x next to the analysts entry, because a colleague had run chmod 755 on the tree. The administrator restores the mask with setfacl -R -m m::rwx, saves a getfacl backup for future recovery, and write access returns within minutes.