Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / man / man1 / setfacl.1
blob11c7b644f34b2c9ecfb5845c9ad11c707de12fd3
1 '\" te
2 .\"  Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SETFACL 1 "Dec 19, 2006"
7 .SH NAME
8 setfacl \- modify the Access Control List (ACL) for a file or files
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBsetfacl\fR [\fB-r\fR] \fB-s\fR \fIacl_entries\fR \fIfile\fR
13 .fi
15 .LP
16 .nf
17 \fBsetfacl\fR [\fB-r\fR] \fB-md\fR \fIacl_entries\fR \fIfile\fR
18 .fi
20 .LP
21 .nf
22 \fBsetfacl\fR [\fB-r\fR] \fB-f\fR \fIacl_file\fR \fIfile\fR
23 .fi
25 .SH DESCRIPTION
26 .sp
27 .LP
28 For each file specified, \fBsetfacl\fR either replaces its entire \fBACL\fR,
29 including the default \fBACL\fR on a directory, or it adds, modifies, or
30 deletes one or more \fBACL\fR entries, including default entries on
31 directories.
32 .sp
33 .LP
34 When the \fBsetfacl\fR command is used, it can result in changes to the file
35 permission bits. When the user \fBACL\fR entry for the file owner is changed,
36 the file owner class permission bits are modified. When the group \fBACL\fR
37 entry for the file group class is changed, the file group class permission bits
38 are modified. When the other \fBACL\fR entry is changed, the file other class
39 permission bits are modified.
40 .sp
41 .LP
42 If you use the \fBchmod\fR(1) command to change the file group owner
43 permissions on a file with \fBACL\fR entries, both the file group owner
44 permissions and the \fBACL\fR mask are changed to the new permissions. Be aware
45 that the new \fBACL\fR mask permissions can change the effective permissions
46 for additional users and groups who have \fBACL\fR entries on the file.
47 .sp
48 .LP
49 A directory can contain default \fBACL\fR entries. If a file or directory is
50 created in a directory that contains default \fBACL\fR entries, the newly
51 created file has permissions generated according to the intersection of the
52 default \fBACL\fR entries and the permissions requested at creation time. The
53 \fBumask\fR(1) are not applied if the directory contains default \fBACL\fR
54 entries. If a default \fBACL\fR is specified for a specific user (or users),
55 the file has a regular \fBACL\fR created. Otherwise, only the mode bits are
56 initialized according to the intersection described above. The default
57 \fBACL\fR should be thought of as the maximum discretionary access permissions
58 that can be granted.
59 .sp
60 .LP
61 Use the \fBsetfacl\fR command to set ACLs on files in a UFS file system, which
62 supports POSIX-draft ACLS (or \fBaclent_t\fR style ACLs). Use the \fBchmod\fR
63 command to set ACLs on files in a ZFS file system, which supports NFSv4-style
64 ACLS (or \fBace_t\fR style ACLs).
65 .SS "\fIacl_entries\fR Syntax"
66 .sp
67 .LP
68 For the \fB-m\fR and \fB-s\fR options, \fIacl_entries\fR are one or more
69 comma-separated \fBACL\fR entries.
70 .sp
71 .LP
72 An \fBACL\fR entry consists of the following fields separated by colons:
73 .sp
74 .ne 2
75 .na
76 \fB\fIentry_type\fR\fR
77 .ad
78 .RS 14n
79 Type of \fBACL\fR entry on which to set file permissions. For example,
80 \fIentry_type\fR can be \fBuser\fR (the owner of a file) or \fBmask\fR (the
81 \fBACL\fR mask).
82 .RE
84 .sp
85 .ne 2
86 .na
87 \fB\fIuid\fR or \fIgid\fR\fR
88 .ad
89 .RS 14n
90 User name or user identification number. Or, group name or group identification
91 number.
92 .RE
94 .sp
95 .ne 2
96 .na
97 \fB\fIperms\fR\fR
98 .ad
99 .RS 14n
100 Represents the permissions that are set on \fIentry_type\fR. \fIperms\fR can be
101 indicated by the symbolic characters \fBrwx\fR or a number (the same
102 permissions numbers used with the \fBchmod\fR command).
107 The following table shows the valid \fBACL\fR entries (default entries can only
108 be specified for directories):
113 c c
114 l l .
115 \fBACL\fR Entry Description
117 u[ser]::\fIperms\fR     File owner permissions.
118 g[roup]::\fIperms\fR    File group owner permissions.
119 o[ther]:\fIperms\fR     T{
120 Permissions for users other than the file owner or members of file group owner.
122 m[ask]:\fIperms\fR      T{
123 The \fBACL\fR mask. The mask entry indicates the maximum permissions allowed for users (other than the owner) and for groups. The mask is a quick way to change permissions on all the users and groups.
125 u[ser]:\fIuid:perms\fR  T{
126 Permissions for a specific user. For \fIuid\fR, you can specify either a user name or a numeric UID.
128 g[roup]:\fIgid:perms\fR T{
129 Permissions for a specific group. For \fIgid\fR, you can specify either a group name or a numeric GID.
131 d[efault]:u[ser]::\fIperms\fR   Default file owner permissions.
132 d[efault]:g[roup]::\fIperms\fR  Default file group owner permissions.
133 d[efault]:o[ther]:\fIperms\fR   T{
134 Default permissions for users other than the file owner or members of the file group owner.
136 d[efault]:m[ask]:\fIperms\fR    Default \fBACL\fR mask.
137 d[efault]:u[ser]:\fIuid\fR:\fIperms\fR  T{
138 Default permissions for a specific user. For \fIuid\fR, you can specify either a user name or a numeric UID.
140 d[efault]:g[roup]:\fIgid\fR:\fIperms\fR T{
141 Default permissions for a specific group. For \fIgid\fR, you can specify either a group name or a numeric GID.
147 For the \fB-d\fR option, \fIacl_entries\fR are one or more comma-separated
148 \fBACL\fR entries without permissions. Notice that the entries for file owner,
149 file group owner, \fBACL\fR mask, and others can not be deleted.
150 .SH OPTIONS
153 The options have the following meaning:
155 .ne 2
157 \fB\fB-d\fR \fIacl_entries\fR\fR
159 .RS 18n
160 Deletes one or more entries from the file. The entries for the file owner, the
161 file group owner, and others can not be deleted from the \fBACL\fR. Notice that
162 deleting an entry does not necessarily have the same effect as removing all
163 permissions from the entry.
167 .ne 2
169 \fB\fB-f\fR \fIacl_file\fR\fR
171 .RS 18n
172 Sets a file's \fBACL\fR with the \fBACL\fR entries contained in the file named
173 \fIacl_file\fR. The same constraints on specified entries hold as with the
174 \fB-s\fR option. The entries are not required to be in any specific order in
175 the file. Also, if you specify a dash (\fB-\fR) for \fIacl_file\fR, standard
176 input is used to set the file's \fBACL\fR.
178 The character \fB#\fR in \fIacl_file\fR can be used to indicate a comment. All
179 characters, starting with the \fB#\fR until the end of the line, are ignored.
180 Notice that if the \fIacl_file\fR has been created as the output of the
181 \fBgetfacl\fR(1) command, any effective permissions, which follow a \fB#\fR,
182 are ignored.
186 .ne 2
188 \fB\fB-m\fR \fIacl_entries\fR\fR
190 .RS 18n
191 Adds one or more new \fBACL\fR entries to the file, and/or modifies one or more
192 existing \fBACL\fR entries on the file. If an entry already exists for a
193 specified \fIuid\fR or \fIgid\fR, the specified permissions replace the current
194 permissions. If an entry does not exist for the specified \fIuid\fR or
195 \fIgid\fR, an entry is created. When using the \fB-m\fR option to modify a
196 default \fBACL\fR, you must specify a complete default \fBACL\fR (user, group,
197 other, mask, and any additional entries) the first time.
201 .ne 2
203 \fB\fB-r\fR\fR
205 .RS 18n
206 Recalculates the permissions for the \fBACL\fR mask entry. The permissions
207 specified in the \fBACL\fR mask entry are ignored and replaced by the maximum
208 permissions necessary to grant the access to all additional user, file group
209 owner, and additional group entries in the \fBACL\fR. The permissions in the
210 additional user, file group owner, and additional group entries are left
211 unchanged.
215 .ne 2
217 \fB\fB-s\fR \fIacl_entries\fR\fR
219 .RS 18n
220 Sets a file's \fBACL\fR. All old \fBACL\fR entries are removed and replaced
221 with the newly specified \fBACL\fR. The entries need not be in any specific
222 order. They are sorted by the command before being applied to the file.
224 Required entries:
225 .RS +4
227 .ie t \(bu
228 .el o
229 Exactly one \fBuser\fR entry specified for the file owner.
231 .RS +4
233 .ie t \(bu
234 .el o
235 Exactly one \fBgroup\fR entry for the file group owner.
237 .RS +4
239 .ie t \(bu
240 .el o
241 Exactly one \fBother\fR entry specified.
243 If there are additional user and group entries:
244 .RS +4
246 .ie t \(bu
247 .el o
248 Exactly one \fBmask\fR entry specified for the \fBACL\fR mask that indicates
249 the maximum permissions allowed for users (other than the owner) and groups.
251 .RS +4
253 .ie t \(bu
254 .el o
255 Must not be duplicate \fBuser\fR entries with the same \fIuid\fR.
257 .RS +4
259 .ie t \(bu
260 .el o
261 Must not be duplicate \fBgroup\fR entries with the same \fIgid\fR.
263 If \fIfile\fR is a directory, the following default \fBACL\fR entries can be
264 specified:
265 .RS +4
267 .ie t \(bu
268 .el o
269 Exactly one \fBdefault user\fR entry for the file owner.
271 .RS +4
273 .ie t \(bu
274 .el o
275 Exactly one \fBdefault group\fR entry for the file group owner.
277 .RS +4
279 .ie t \(bu
280 .el o
281 Exactly one \fBdefault mask\fR entry for the \fBACL\fR mask.
283 .RS +4
285 .ie t \(bu
286 .el o
287 Exactly one \fBdefault other\fR entry.
289 There can be additional \fBdefault user\fR entries and additional \fBdefault
290 group\fR entries specified, but there can not be duplicate additional
291 \fBdefault user\fR entries with the same \fIuid\fR, or duplicate \fBdefault
292 group\fR entries with the same \fIgid\fR.
295 .SH EXAMPLES
297 \fBExample 1 \fRAdding read permission only
300 The following example adds one \fBACL\fR entry to file \fBabc\fR, which gives
301 user \fBshea\fR read permission only.
304 .in +2
306 \fBsetfacl -m user:shea:r\(mi\(mi abc\fR
308 .in -2
312 \fBExample 2 \fRReplacing a file's entire \fBACL\fR
315 The following example replaces the entire \fBACL\fR for the file \fBabc\fR,
316 which gives \fBshea\fR read access, the file owner all access, the file group
317 owner read access only, the \fBACL\fR mask read access only, and others no
318 access.
321 .in +2
323 \fBsetfacl -s user:shea:rwx,user::rwx,group::rw-,mask:r--,other:--- abc\fR
325 .in -2
330 Notice that after this command, the file permission bits are \fBrwxr-----\fR.
331 Even though the file group owner was set with read/write permissions, the
332 \fBACL\fR mask entry limits it to have only read permission. The mask entry
333 also specifies the maximum permissions available to all additional user and
334 group \fBACL\fR entries. Once again, even though the user \fBshea\fR was set
335 with all access, the mask limits it to have only read permission. The \fBACL\fR
336 mask entry is a quick way to limit or open access to all the user and group
337 entries in an \fBACL\fR. For example, by changing the mask entry to read/write,
338 both the file group owner and user \fBshea\fR would be given read/write access.
341 \fBExample 3 \fRSetting the same \fBACL\fR on two files
344 The following example sets the same \fBACL\fR on file \fBabc\fR as the file
345 \fBxyz\fR.
348 .in +2
350 \fBgetfacl xyz | setfacl -f \(mi abc\fR
352 .in -2
355 .SH FILES
357 .ne 2
359 \fB\fB/etc/passwd\fR\fR
361 .RS 15n
362 password file
366 .ne 2
368 \fB\fB/etc/group\fR\fR
370 .RS 15n
371 group file
374 .SH SEE ALSO
377 \fBchmod\fR(1), \fBgetfacl\fR(1), \fBumask\fR(1), \fBaclcheck\fR(3SEC),
378 \fBaclsort\fR(3SEC), \fBgroup\fR(4), \fBpasswd\fR(4), \fBattributes\fR(5)