1SETFACL(1)                   Access Control Lists                   SETFACL(1)
2
3
4

NAME

6       setfacl - set file access control lists
7

SYNOPSIS

9       setfacl -bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...
10
11       setfacl --restore=file
12
13

DESCRIPTION

15       This utility sets Access Control Lists (ACLs) of files and directories.
16       On the command line, a sequence of commands is followed by  a  sequence
17       of  files  (which  in  turn can be followed by another sequence of com‐
18       mands, ...).
19
20       The options -m, and -x expect an ACL on the command line. Multiple  ACL
21       entries are separated by comma characters (`,'). The options -M, and -X
22       read an ACL from a file or from standard input. The ACL entry format is
23       described in Section ACL ENTRIES.
24
25       The  --set and --set-file options set the ACL of a file or a directory.
26       The previous ACL is replaced.  ACL  entries  for  this  operation  must
27       include permissions.
28
29       The  -m  (--modify)  and -M (--modify-file) options modify the ACL of a
30       file or directory.  ACL entries for this operation must include permis‐
31       sions.
32
33       The  -x  (--remove)  and  -X (--remove-file) options remove ACL enries.
34       Only ACL entries without the perms field are  accepted  as  parameters,
35       unless POSIXLY_CORRECT is defined.
36
37       When  reading  from files using the -M, and -X options, setfacl accepts
38       the output getfacl produces.  There is at most one ACL entry per  line.
39       After  a  Pound  sign  (`#'),  everything  up to the end of the line is
40       treated as a comment.
41
42       If setfacl is used on a file system which does not support  ACLs,  set‐
43       facl operates on the file mode permission bits. If the ACL does not fit
44       completely in the permission bits, setfacl modifies the file mode  per‐
45       mission bits to reflect the ACL as closely as possible, writes an error
46       message to standard error, and returns with an exit status greater than
47       0.
48
49
50   PERMISSIONS
51       The  file  owner  and  processes  capable of CAP_FOWNER are granted the
52       right to modify ACLs of a file. This is analogous  to  the  permissions
53       required  for  accessing the file mode. (On current Linux systems, root
54       is the only user with the CAP_FOWNER capability.)
55
56
57   OPTIONS
58       -b, --remove-all
59           Remove all extended ACL entries. The base ACL entries of the owner,
60           group and others are retained.
61
62       -k, --remove-default
63           Remove  the  Default ACL. If no Default ACL exists, no warnings are
64           issued.
65
66       -n, --no-mask
67           Do not recalculate the effective rights mask. The default  behavior
68           of  setfacl  is  to  recalculate  the ACL mask entry, unless a mask
69           entry was explicitly given.  The mask entry is set to the union  of
70           all  permissions  of the owning group, and all named user and group
71           entries. (These are  exactly  the  entries  affected  by  the  mask
72           entry).
73
74       --mask
75           Do recalculate the effective rights mask, even if an ACL mask entry
76           was explicitly given. (See the -n option.)
77
78       -d, --default
79           All operations apply to the Default ACL. Regular ACL entries in the
80           input  set are promoted to Default ACL entries. Default ACL entries
81           in the input set are discarded. (A warning is issued if  that  hap‐
82           pens).
83
84       --restore=file
85           Restore a permission backup created by `getfacl -R' or similar. All
86           permissions of a complete directory subtree are restored using this
87           mechanism.  If the input contains owner comments or group comments,
88           and setfacl is run by root, the owner and owning group of all files
89           are  restored  as  well.  This  option  cannot  be mixed with other
90           options except `--test'.
91
92       --test
93           Test mode. Instead of changing the ACLs of any files, the resulting
94           ACLs are listed.
95
96       -R, --recursive
97           Apply  operations  to  all  files and directories recursively. This
98           option cannot be mixed with `--restore'.
99
100       -L, --logical
101           Logical walk, follow symbolic links. The  default  behavior  is  to
102           follow  symbolic link arguments, and to skip symbolic links encoun‐
103           tered  in  subdirectories.  This  option  cannot  be   mixed   with
104           `--restore'.
105
106       -P, --physical
107           Physical  walk,  skip  all symbolic links. This also skips symbolic
108           link arguments.  This option cannot be mixed with `--restore'.
109
110       --version
111           Print the version of setfacl and exit.
112
113       --help
114           Print help explaining the command line options.
115
116       --  End of command line options. All remaining  parameters  are  inter‐
117           preted as file names, even if they start with a dash.
118
119       -   If  the  file name parameter is a single dash, setfacl reads a list
120           of files from standard input.
121
122
123   ACL ENTRIES
124       The setfacl utility recognizes the following ACL entry formats  (blanks
125       inserted for clarity):
126
127
128       [d[efault]:] [u[ser]:]uid [:perms]
129              Permissions  of  a  named user. Permissions of the file owner if
130              uid is empty.
131
132       [d[efault]:] g[roup]:gid [:perms]
133              Permissions of a named group. Permissions of the owning group if
134              gid is empty.
135
136       [d[efault]:] m[ask][:] [:perms]
137              Effective rights mask
138
139       [d[efault]:] o[ther][:] [:perms]
140              Permissions of others.
141
142       Whitespace between delimiter characters and non-delimiter characters is
143       ignored.
144
145       Proper ACL entries including permissions are used  in  modify  and  set
146       operations.  (options  -m,  -M, --set and --set-file).  Entries without
147       the perms field are used for deletion of entries (options -x and -X).
148
149       For uid and gid you can specify either a name or a number.
150
151       The perms field is a combination of characters that indicate  the  per‐
152       missions: read (r), write (w), execute (x), execute only if the file is
153       a directory or already  has  execute  permission  for  some  user  (X).
154       Alternatively, the perms field can be an octal digit (0-7).
155
156   AUTOMATICALLY CREATED ENTRIES
157       Initially,  files  and  directories  contain  only  the  three base ACL
158       entries for the owner, the group, and others. There are some rules that
159       need to be satisfied in order for an ACL to be valid:
160
161       *   The three base entries cannot be removed. There must be exactly one
162           entry of each of these base entry types.
163
164       *   Whenever an ACL contains named user entries or named group objects,
165           it must also contain an effective rights mask.
166
167       *   Whenever an ACL contains any Default ACL entries, the three Default
168           ACL base entries (default owner, default group, and default others)
169           must also exist.
170
171       *   Whenever  a  Default ACL contains named user entries or named group
172           objects, it must also contain a default effective rights mask.
173
174       To help the user ensure  these  rules,  setfacl  creates  entries  from
175       existing entries under the following conditions:
176
177       *   If  an  ACL contains named user or named group entries, and no mask
178           entry exists, a mask entry containing the same permissions  as  the
179           group  entry is created. Unless the -n option is given, the permis‐
180           sions of the mask entry are further adjusted to include  the  union
181           of  all  permissions affected by the mask entry. (See the -n option
182           description).
183
184       *   If a Default ACL entry is created, and the Default ACL contains  no
185           owner, owning group, or others entry, a copy of the ACL owner, own‐
186           ing group, or others entry is added to the Default ACL.
187
188       *   If a Default  ACL  contains  named  user  entries  or  named  group
189           entries, and no mask entry exists, a mask entry containing the same
190           permissions as the default Default  ACL's  group  entry  is  added.
191           Unless  the  -n  option is given, the permissions of the mask entry
192           are further adjusted to inclu  de  the  union  of  all  permissions
193           affected by the mask entry. (See the -n option description).
194

EXAMPLES

196       Granting an additional user read access
197              setfacl -m u:lisa:r file
198
199       Revoking  write  access  from all groups and all named users (using the
200       effective rights mask)
201              setfacl -m m::rx file
202
203       Removing a named group entry from a file's ACL
204              setfacl -x g:staff file
205
206       Copying the ACL of one file to another
207              getfacl file1 | setfacl --set-file=- file2
208
209       Copying the access ACL into the Default ACL
210              getfacl --access dir | setfacl -d -M- dir
211

CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17

213       If the environment variable POSIXLY_CORRECT  is  defined,  the  default
214       behavior  of  setfacl  changes as follows: All non-standard options are
215       disabled.  The ``default:'' prefix is disabled.  The -x and -X  options
216       also accept permission fields (and ignore them).
217

AUTHOR

219       Andreas Gruenbacher, <a.gruenbacher@bestbits.at>.
220
221       Please  send  your  bug reports, suggested features and comments to the
222       above address.
223

SEE ALSO

225       getfacl(1), chmod(1), umask(1), acl(5)
226
227
228
229May 2000                      ACL File Utilities                    SETFACL(1)
Impressum