Pcornel
Linux · Permissions & Ownership

getfacl / setfacl

Cheat sheet · https://pcornel.dk/topic.php?topic=2712

Back to the Topic

Answer

getfacl shows a file's ACL; setfacl -m adds or changes entries, -x removes one, -b removes all, and -d sets default (inherited) entries on directories.

Remember

Use capital X so files do not become executable. Apply to existing trees with -R and set defaults with -d for new files. Back up ACLs with getfacl -R <dir> > acl.txt and restore with setfacl --restore=acl.txt.

First checks

  • getfacl -R <dir> > acl.txt — back up ACLs
  • ls -l <path> — owner, group and mode
  • stat -c '%A %a %U:%G' <path> — symbolic and numeric mode with owner
  • namei -l <path> — permissions of every directory on the path
  • id <user> — user's groups

Verify in this order

setfacl changes entries → mask recalculated → getfacl shows effective rights → kernel enforces them

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2712

Confirmation

Confirm action

Continue?