Linux "setfacl" Command Line Options and Examples
set file access control lists

This utility sets Access Control Lists (ACLs) of files and directories. On the command line, a sequence of commands is followed by a sequence of files (which in turn can be followed by another sequence of commands, ..


Usage:

setfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...


    setfacl --restore=file






Command Line Options:

-b
Remove all extended ACL entries. The base ACL entries of the owner, group and others are retained.
setfacl -b ...
-k
Remove the Default ACL. If no Default ACL exists, no warnings are issued.
setfacl -k ...
-n
Do not recalculate the effective rights mask. The default behavior of setfacl is to recalculate the ACLmask entry, unless a mask entry was explicitly given. The mask entry is set to the union of all permis‐sions of the owning group, and all named user and group entries. (These are exactly the entries affectedby the mask entry).
setfacl -n ...
--mask
Do recalculate the effective rights mask, even if an ACL mask entry was explicitly given. (See the -noption.)
setfacl --mask ...
-d
All operations apply to the Default ACL. Regular ACL entries in the input set are promoted to Default ACLentries. Default ACL entries in the input set are discarded. (A warning is issued if that happens).
setfacl -d ...
--restore
Restore a permission backup created by `getfacl -R' or similar. All permissions of a complete directorysubtree are restored using this mechanism. If the input contains owner comments or group comments, setfaclattempts to restore the owner and owning group. If the input contains flags comments (which define thesetuid, setgid, and sticky bits), setfacl sets those three bits accordingly; otherwise, it clears them.This option cannot be mixed with other options except `--test'.
setfacl --restore ...
--test
Test mode. Instead of changing the ACLs of any files, the resulting ACLs are listed.
setfacl --test ...
-R
Apply operations to all files and directories recursively. This option cannot be mixed with `--restore'.
setfacl -R ...
-L
Logical walk, follow symbolic links to directories. The default behavior is to follow symbolic link argu‐ments, and skip symbolic links encountered in subdirectories. Only effective in combination with -R.This option cannot be mixed with `--restore'.
setfacl -L ...
-P
Physical walk, do not follow symbolic links to directories. This also skips symbolic link arguments.Only effective in combination with -R. This option cannot be mixed with `--restore'.
setfacl -P ...
-v
Print the version of setfacl and exit.
setfacl -v ...
-h
Print help explaining the command line options.
setfacl -h ...
-
ACL ENTRIESThe setfacl utility recognizes the following ACL entry formats (blanks inserted for clarity):[d[efault]:] [u[ser]:]uid [:perms]Permissions of a named user. Permissions of the file owner if uid is empty.[d[efault]:] g[roup]:gid [:perms]Permissions of a named group. Permissions of the owning group if gid is empty.[d[efault]:] m[ask][:] [:perms]Effective rights mask[d[efault]:] o[ther][:] [:perms]Permissions of others.Whitespace between delimiter characters and non-delimiter characters is ignored.Proper ACL entries including permissions are used in modify and set operations. (options -m, -M, --set and
setfacl - ...
--set-file).
For uid and gid you can specify either a name or a number.The perms field is a combination of characters that indicate the permissions: read (r), write (w), execute(x), execute only if the file is a directory or already has execute permission for some user (X). Alterna‐tively, the perms field can be an octal digit (0-7).AUTOMATICALLY CREATED ENTRIESInitially, files and directories contain only the three base ACL entries for the owner, the group, and others.There are some rules that need to be satisfied in order for an ACL to be valid:* The three base entries cannot be removed. There must be exactly one entry of each of these base entrytypes.* Whenever an ACL contains named user entries or named group objects, it must also contain an effectiverights mask.* Whenever an ACL contains any Default ACL entries, the three Default ACL base entries (default owner,default group, and default others) must also exist.* Whenever a Default ACL contains named user entries or named group objects, it must also contain a defaulteffective rights mask.To help the user ensure these rules, setfacl creates entries from existing entries under the following condi‐tions:* If an ACL contains named user or named group entries, and no mask entry exists, a mask entry containingthe same permissions as the group entry is created. Unless the -n option is given, the permissions of themask entry are further adjusted to include the union of all permissions affected by the mask entry. (Seethe -n option description).* If a Default ACL entry is created, and the Default ACL contains no owner, owning group, or others entry, acopy of the ACL owner, owning group, or others entry is added to the Default ACL.* If a Default ACL contains named user entries or named group entries, and no mask entry exists, a maskentry containing the same permissions as the default Default ACL's group entry is added. Unless the -noption is given, the permissions of the mask entry are further adjusted to inclu de the union of all per‐missions affected by the mask entry. (See the -n option description).EXAMPLESGranting an additional user read accesssetfacl -m u:lisa:r fileRevoking write access from all groups and all named users (using the effective rights mask)setfacl -m m::rx fileRemoving a named group entry from a file's ACLsetfacl -x g:staff fileCopying the ACL of one file to anothergetfacl file1 | setfacl --set-file=- file2Copying the access ACL into the Default ACLgetfacl --access dir | setfacl -d -M- dirCONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17If the environment variable POSIXLY_CORRECT is defined, the default behavior of setfacl changes as follows:All non-standard options are disabled. The ``default:'' prefix is disabled. The -x and -X options alsoaccept permission fields (and ignore them).AUTHORAndreas Gruenbacher, <a.gruenbacher@bestbits.at>.Please send your bug reports, suggested features and comments to the above address.
setfacl --set-file). ...