1SETFACL(1) Access Control Lists SETFACL(1)
2
3
4
6 setfacl - set file access control lists
7
9 setfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ...
10
11 setfacl --restore=file
12
13
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 entries.
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 setfacl attempts to restore the owner and owning group. If the
89 input contains flags comments (which define the setuid, setgid, and
90 sticky bits), setfacl sets those three bits accordingly; otherwise,
91 it clears them. This option cannot be mixed with other options
92 except `--test'.
93
94 --test
95 Test mode. Instead of changing the ACLs of any files, the resulting
96 ACLs are listed.
97
98 -R, --recursive
99 Apply operations to all files and directories recursively. This
100 option cannot be mixed with `--restore'.
101
102 -L, --logical
103 Logical walk, follow symbolic links to directories. The default
104 behavior is to follow symbolic link arguments, and skip symbolic
105 links encountered in subdirectories. Only effective in combination
106 with -R. This option cannot be mixed with `--restore'.
107
108 -P, --physical
109 Physical walk, do not follow symbolic links to directories. This
110 also skips symbolic link arguments. Only effective in combination
111 with -R. This option cannot be mixed with `--restore'.
112
113 -v, --version
114 Print the version of setfacl and exit.
115
116 -h, --help
117 Print help explaining the command line options.
118
119 -- End of command line options. All remaining parameters are inter‐
120 preted as file names, even if they start with a dash.
121
122 - If the file name parameter is a single dash, setfacl reads a list
123 of files from standard input.
124
125
126 ACL ENTRIES
127 The setfacl utility recognizes the following ACL entry formats (blanks
128 inserted for clarity):
129
130
131 [d[efault]:] [u[ser]:]uid [:perms]
132 Permissions of a named user. Permissions of the file owner if
133 uid is empty.
134
135 [d[efault]:] g[roup]:gid [:perms]
136 Permissions of a named group. Permissions of the owning group if
137 gid is empty.
138
139 [d[efault]:] m[ask][:] [:perms]
140 Effective rights mask
141
142 [d[efault]:] o[ther][:] [:perms]
143 Permissions of others.
144
145 Whitespace between delimiter characters and non-delimiter characters is
146 ignored.
147
148 Proper ACL entries including permissions are used in modify and set
149 operations. (options -m, -M, --set and --set-file). Entries without
150 the perms field are used for deletion of entries (options -x and -X).
151
152 For uid and gid you can specify either a name or a number.
153
154 The perms field is a combination of characters that indicate the per‐
155 missions: read (r), write (w), execute (x), execute only if the file is
156 a directory or already has execute permission for some user (X).
157 Alternatively, the perms field can be an octal digit (0-7).
158
159 AUTOMATICALLY CREATED ENTRIES
160 Initially, files and directories contain only the three base ACL
161 entries for the owner, the group, and others. There are some rules that
162 need to be satisfied in order for an ACL to be valid:
163
164 * The three base entries cannot be removed. There must be exactly one
165 entry of each of these base entry types.
166
167 * Whenever an ACL contains named user entries or named group objects,
168 it must also contain an effective rights mask.
169
170 * Whenever an ACL contains any Default ACL entries, the three Default
171 ACL base entries (default owner, default group, and default others)
172 must also exist.
173
174 * Whenever a Default ACL contains named user entries or named group
175 objects, it must also contain a default effective rights mask.
176
177 To help the user ensure these rules, setfacl creates entries from
178 existing entries under the following conditions:
179
180 * If an ACL contains named user or named group entries, and no mask
181 entry exists, a mask entry containing the same permissions as the
182 group entry is created. Unless the -n option is given, the permis‐
183 sions of the mask entry are further adjusted to include the union
184 of all permissions affected by the mask entry. (See the -n option
185 description).
186
187 * If a Default ACL entry is created, and the Default ACL contains no
188 owner, owning group, or others entry, a copy of the ACL owner, own‐
189 ing group, or others entry is added to the Default ACL.
190
191 * If a Default ACL contains named user entries or named group
192 entries, and no mask entry exists, a mask entry containing the same
193 permissions as the default Default ACL's group entry is added.
194 Unless the -n option is given, the permissions of the mask entry
195 are further adjusted to include the union of all permissions
196 affected by the mask entry. (See the -n option description).
197
199 Granting an additional user read access
200 setfacl -m u:lisa:r file
201
202 Revoking write access from all groups and all named users (using the
203 effective rights mask)
204 setfacl -m m::rx file
205
206 Removing a named group entry from a file's ACL
207 setfacl -x g:staff file
208
209 Copying the ACL of one file to another
210 getfacl file1 | setfacl --set-file=- file2
211
212 Copying the access ACL into the Default ACL
213 getfacl --access dir | setfacl -d -M- dir
214
216 If the environment variable POSIXLY_CORRECT is defined, the default
217 behavior of setfacl changes as follows: All non-standard options are
218 disabled. The ``default:'' prefix is disabled. The -x and -X options
219 also accept permission fields (and ignore them).
220
222 Andreas Gruenbacher, <a.gruenbacher@bestbits.at>.
223
224 Please send your bug reports, suggested features and comments to the
225 above address.
226
228 getfacl(1), chmod(1), umask(1), acl(5)
229
230
231
232May 2000 ACL File Utilities SETFACL(1)