What it does
getfacl shows the owner, group and normal permissions plus the extra ACL entries: rights for named users and groups, the mask, and default entries that new files inherit. A + after the mode in ls -l tells you a file has an ACL.
The output format can be used to restore ACLs with setfacl --restore.
How to write it
getfacl [-aceEsRLPtpndvh] FILE...Options 14
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Show the ACL of a folder
getfacl /srv/sales # file: srv/sales # owner: root # group: sales # flags: -st user::rwx user:carol:r-x group::rwx group:account:r-x mask::rwx other::--- default:user::rwx default:group::rwx default:group:account:r-x default:mask::rwx default:other::---flags -st = SGID and sticky; default lines are for new files.
2See which files have an ACL
ls -l /srv/sales drwxrws--T+ 2 root sales 22 Oct 25 11:00 /srv/salesThe + means an ACL.
3Only the extra entries
getfacl -cs /srv/sales/*Skips files without ACL and the header.
4Effective rights after the mask
getfacl /srv/sales/new.txt group:account:r-x #effective:r--The mask removes x: account can only read.
5Back up all ACLs of a tree
getfacl -R /srv > /root/srv-acl.txtRestore with
setfacl --restore=/root/srv-acl.txt.6Only the default ACL
getfacl -d /srv/salesWhat new files will get.
7Copy an ACL to another file
getfacl plan.txt | setfacl --set-file=- report.txtSame ACL on report.txt.
8Numbers instead of names
getfacl -n /srv/restoreHelps when users from another server do not exist here.
9Audit folders with extra access (security)
getfacl -R -s -p /srv 2>/dev/null | grep -E '^(# file|user:|group:)'Lists who got extra rights beyond the normal mode.
10Table view
getfacl -t /srv/salesAccess and default in columns.
Nothing matches this filter.
Watch out
Exit codes
0 :: Done. 1 :: Error.