{
    "mode": "man",
    "parameter": "setfacl",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/setfacl/1/json",
    "generated": "2026-05-30T05:11:42Z",
    "synopsis": "setfacl [-bkndRLPvh] [{-m|-x} aclspec] [{-M|-X} aclfile] file ...\nsetfacl --restore={file|-}",
    "sections": {
        "NAME": {
            "content": "setfacl - set file access control lists\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "setfacl [-bkndRLPvh] [{-m|-x} aclspec] [{-M|-X} aclfile] file ...\n\nsetfacl --restore={file|-}\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This utility sets Access Control Lists (ACLs) of files and directories.  On the command line,\na sequence of commands is followed by a sequence of files (which in turn can be  followed  by\nanother sequence of commands, ...).\n\nThe  -m  and -x options expect an ACL on the command line. Multiple ACL entries are separated\nby comma characters (`,'). The -M and -X options read an ACL from a file or from standard in‐\nput. The ACL entry format is described in Section ACL ENTRIES.\n\nThe  --set  and  --set-file options set the ACL of a file or a directory. The previous ACL is\nreplaced.  ACL entries for this operation must include permissions.\n\nThe -m (--modify) and -M (--modify-file) options modify the ACL of a file or directory.   ACL\nentries for this operation must include permissions.\n\nThe  -x  (--remove)  and -X (--remove-file) options remove ACL entries. It is not an error to\nremove an entry which does not exist.  Only ACL entries without the perms field are  accepted\nas parameters, unless POSIXLYCORRECT is defined.\n\nWhen  reading from files using the -M and -X options, setfacl accepts the output getfacl pro‐\nduces.  There is at most one ACL entry per line. After a Pound sign (`#'), everything  up  to\nthe end of the line is treated as a comment.\n\nIf setfacl is used on a file system which does not support ACLs, setfacl operates on the file\nmode permission bits. If the ACL does not fit completely in the permission bits, setfacl mod‐\nifies  the file mode permission bits to reflect the ACL as closely as possible, writes an er‐\nror message to standard error, and returns with an exit status greater than 0.\n\n\nPERMISSIONS\nThe file owner and processes capable of CAPFOWNER are granted the right to modify ACLs of  a\nfile.  This is analogous to the permissions required for accessing the file mode. (On current\nLinux systems, root is the only user with the CAPFOWNER capability.)\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "-b, --remove-all\nRemove all extended ACL entries. The base ACL entries of the owner, group and others  are\nretained.\n\n-k, --remove-default\nRemove the Default ACL. If no Default ACL exists, no warnings are issued.\n\n-n, --no-mask\nDo  not  recalculate the effective rights mask. The default behavior of setfacl is to re‐\ncalculate the ACL mask entry, unless a mask entry was explicitly given.  The  mask  entry\nis  set to the union of all permissions of the owning group, and all named user and group\nentries. (These are exactly the entries affected by the mask entry).\n\n--mask\nDo recalculate the effective rights mask, even if an ACL mask entry was explicitly given.\n(See the -n option.)\n\n-d, --default\nAll  operations  apply  to the Default ACL. Regular ACL entries in the input set are pro‐\nmoted to Default ACL entries. Default ACL entries in the  input  set  are  discarded.  (A\nwarning is issued if that happens).\n\n--restore={file|-}\nRestore a permission backup created by `getfacl -R' or similar. All permissions of a com‐\nplete directory subtree are restored using this mechanism. If the  input  contains  owner\ncomments  or  group  comments, setfacl attempts to restore the owner and owning group. If\nthe input contains flags comments (which define the setuid,  setgid,  and  sticky  bits),\nsetfacl  sets those three bits accordingly; otherwise, it clears them. This option cannot\nbe mixed with other options except `--test'.  If the file specified is '-', then it  will\nbe read from standard input.\n\n--test\nTest mode. Instead of changing the ACLs of any files, the resulting ACLs are listed.\n\n-R, --recursive\nApply  operations  to  all files and directories recursively. This option cannot be mixed\nwith `--restore'.\n\n-L, --logical\nLogical walk, follow symbolic links to directories. The default  behavior  is  to  follow\nsymbolic link arguments, and skip symbolic links encountered in subdirectories.  Only ef‐\nfective in combination with -R.  This option cannot be mixed with `--restore'.\n\n-P, --physical\nPhysical walk, do not follow symbolic links to directories.   This  also  skips  symbolic\nlink arguments.  Only effective in combination with -R.  This option cannot be mixed with\n`--restore'.\n\n-v, --version\nPrint the version of setfacl and exit.\n\n-h, --help\nPrint help explaining the command line options.\n\n--  End of command line options. All remaining parameters are interpreted as file names, even\nif they start with a dash.\n\n-   If  the file name parameter is a single dash, setfacl reads a list of files from standard\ninput.\n\n\nACL ENTRIES\nThe setfacl utility recognizes the following ACL entry formats (blanks inserted for clarity):\n\n\n[d[efault]:] [u[ser]:]uid [:perms]\nPermissions of a named user. Permissions of the file owner if uid is empty.\n\n[d[efault]:] g[roup]:gid [:perms]\nPermissions of a named group. Permissions of the owning group if gid is empty.\n\n[d[efault]:] m[ask][:] [:perms]\nEffective rights mask\n\n[d[efault]:] o[ther][:] [:perms]\nPermissions of others.\n\nWhitespace between delimiter characters and non-delimiter characters is ignored.\n\nProper ACL entries including permissions are used in modify and set operations. (options  -m,\n-M,  --set and --set-file).  Entries without the perms field are used for deletion of entries\n(options -x and -X).\n\nFor uid and gid you can specify either a name or a number.  Character literals may be  speci‐\nfied  with  a  backslash followed by the 3-digit octal digits corresponding to the ASCII code\nfor the character (e.g., \\101 for 'A').  If the name contains a literal backslash followed by\n3 digits, the backslash must be escaped (i.e., \\\\).\n\nThe perms field is a combination of characters that indicate the read (r), write (w), execute\n(x) permissions.  Dash characters in the perms field (-) are ignored.  The character X stands\nfor  the  execute permission if the file is a directory or already has execute permission for\nsome user.  Alternatively, the perms field can define the permissions numerically, as a  bit-\nwise  combination of read (4), write (2), and execute (1).  Zero perms fields or perms fields\nthat only consist of dashes indicate no permissions.\n\nAUTOMATICALLY CREATED ENTRIES\nInitially, files and directories contain only the three base ACL entries for the  owner,  the\ngroup,  and  others. There are some rules that need to be satisfied in order for an ACL to be\nvalid:\n\n*   The three base entries cannot be removed. There must be exactly  one  entry  of  each  of\nthese base entry types.\n\n*   Whenever  an ACL contains named user entries or named group objects, it must also contain\nan effective rights mask.\n\n*   Whenever an ACL contains any Default ACL entries, the three Default ACL base entries (de‐\nfault owner, default group, and default others) must also exist.\n\n*   Whenever  a  Default ACL contains named user entries or named group objects, it must also\ncontain a default effective rights mask.\n\nTo help the user ensure these rules, setfacl creates entries from existing entries under  the\nfollowing conditions:\n\n*   If  an  ACL  contains named user or named group entries, and no mask entry exists, a mask\nentry containing the same permissions as the group entry is created. Unless the -n option\nis  given, the permissions of the mask entry are further adjusted to include the union of\nall permissions affected by the mask entry. (See the -n option description).\n\n*   If a Default ACL entry is created, and the Default ACL contains no owner,  owning  group,\nor  others  entry, a copy of the ACL owner, owning group, or others entry is added to the\nDefault ACL.\n\n*   If a Default ACL contains named user entries or named group entries, and  no  mask  entry\nexists,  a  mask entry containing the same permissions as the default Default ACL's group\nentry is added. Unless the -n option is given, the permissions of the mask entry are fur‐\nther  adjusted  to  include the union of all permissions affected by the mask entry. (See\nthe -n option description).\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Granting an additional user read access\nsetfacl -m u:lisa:r file\n\nRevoking write access from all groups and all named users (using the effective rights mask)\nsetfacl -m m::rx file\n\nRemoving a named group entry from a file's ACL\nsetfacl -x g:staff file\n\nCopying the ACL of one file to another\ngetfacl file1 | setfacl --set-file=- file2\n\nCopying the access ACL into the Default ACL\ngetfacl --access dir | setfacl -d -M- dir\n",
            "subsections": [
                {
                    "name": "CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17",
                    "content": "If the environment variable POSIXLYCORRECT is  defined,  the  default  behavior  of  setfacl\nchanges  as  follows: All non-standard options are disabled.  The ``default:'' prefix is dis‐\nabled.  The -x and -X options also accept permission fields (and ignore them).\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Andreas Gruenbacher, <andreas.gruenbacher@gmail.com>.\n\nPlease send your bug reports, suggested features and comments to the above address.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "getfacl(1), chmod(1), umask(1), acl(5)\n\n\n\nMay 2000                                 ACL File Utilities                               SETFACL(1)",
            "subsections": []
        }
    },
    "summary": "setfacl - set file access control lists",
    "flags": [],
    "examples": [
        "Granting an additional user read access",
        "setfacl -m u:lisa:r file",
        "Revoking write access from all groups and all named users (using the effective rights mask)",
        "setfacl -m m::rx file",
        "Removing a named group entry from a file's ACL",
        "setfacl -x g:staff file",
        "Copying the ACL of one file to another",
        "getfacl file1 | setfacl --set-file=- file2",
        "Copying the access ACL into the Default ACL",
        "getfacl --access dir | setfacl -d -M- dir",
        "If the environment variable POSIXLYCORRECT is  defined,  the  default  behavior  of  setfacl",
        "changes  as  follows: All non-standard options are disabled.  The ``default:'' prefix is dis‐",
        "abled.  The -x and -X options also accept permission fields (and ignore them)."
    ],
    "see_also": [
        {
            "name": "getfacl",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/getfacl/1/json"
        },
        {
            "name": "chmod",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/chmod/1/json"
        },
        {
            "name": "umask",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/umask/1/json"
        },
        {
            "name": "acl",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/acl/5/json"
        }
    ]
}