Permissions and owners

The setfacl command

Grants fine-grained permissions to specific users or groups, beyond the owner, group and others that chmod shows. These are POSIX ACLs: they let ana read a report without making her the owner or adding her to the group. You inspect them with getfacl.

Syntax

setfacl [opciones] -m entrada archivo...Try it in the terminal →

Most useful options

-m, --modify <entrada>Adds or changes an entry. Format type:name:permissions, such as u:ana:rw
-x, --remove <entrada>Removes one entry, without the permissions field: u:ana
-b, --remove-allRemoves all ACL entries and keeps only the basic permissions
-R, --recursiveApplies the change to the folder and all its contents
-d, --defaultSets a default ACL: new files in the folder inherit it

Copy-ready examples

$ setfacl -m u:ana:rw informe.txtgives ana read and write access without changing the file's owner or group.
$ getfacl informe.txtshows the file's ACLs. The user:ana line is the new entry.

Example output

# file: informe.txt
# owner: miguel
# group: miguel
user::rw-
user:ana:rw-
group::r--
mask::rw-
other::r--
$ setfacl -R -m g:devs:rX proyecto/the devs group can read the whole project and enter its folders. The X only grants execute on directories.
$ setfacl -d -m g:devs:rwx proyecto/new files created in proyecto/ will inherit that entry for devs.
$ setfacl -x u:ana informe.txtremoves only ana's entry. The rest of the permissions stays.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
setfacl: informe.txt: Operation not permittedOnly the file owner or root can change its ACL.Run it as the file owner or with sudo, and check the result with getfacl.

Typical mistakes

  • Copies without preservation options, and some backups, drop ACLs. Check that the destination keeps them.

Differences from similar commands

  • chmod: gives permissions only to the owner, the group and others. For one specific user, use setfacl.
  • chown: changes the owner. setfacl grants access to someone without changing the owner.
  • chgrp: changes the file's group. To give several users access without touching it, setfacl is finer-grained.

Security

An entry such as o::rw opens the file to anyone on the system. Check getfacl before granting broad permissions. And remember that chmod changes the ACL mask: after a chmod on the group, the permissions of named users may shrink without warning.

Related commands

FAQ

What does the + mean in ls -l?

That the file has ACLs. Use getfacl to see the specific entries.

How do I remove all ACLs from a file?

With setfacl -b file. Only the basic owner, group and others permissions remain.

Why does my ACL not work on a file on a USB drive?

Because the file system does not support ACLs. ext4, XFS and Btrfs do, while FAT and exFAT do not.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course