2 .\" Copyright (c) 1989, 1990, 1993, 1994
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Institute of Electrical and Electronics Engineers, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
40 .Nd change file modes or Access Control Lists
44 .Op Fl R Op Fl H | L | P
49 .Op Fl R Op Fl H | L | P
55 .Op Fl R Op Fl H | L | P
60 .Op Fl R Op Fl H | L | P
65 .Op Fl R Op Fl H | L | P
71 utility modifies the file mode bits of the listed files
74 operand. It may also be used to modify the Access Control
75 Lists (ACLs) associated with the listed files.
77 The generic options are as follows:
78 .Bl -tag -width indent
80 Do not display a diagnostic message if
82 could not modify the mode for
84 nor modify the exit status to reflect such failures.
88 option is specified, symbolic links on the command line are followed
89 and hence unaffected by the command.
90 (Symbolic links encountered during tree traversal are not followed.)
92 If the file is a symbolic link, change the mode of the link itself
93 rather than the file that the link points to.
97 option is specified, all symbolic links are followed.
101 option is specified, no symbolic links are followed.
104 Change the modes of the file hierarchies rooted in the files,
105 instead of just the files themselves.
106 Beware of unintentionally matching the
108 hard link to the parent directory when using wildcards like
113 to be verbose, showing filenames as the mode is modified.
116 flag is specified more than once, the old and new modes of the file
117 will also be printed, in both octal and symbolic notation.
125 options are ignored unless the
128 In addition, these options override each other and the
129 command's actions are determined by the last one specified.
139 then the current filename as well as the old and new modes are displayed.
141 Only the owner of a file or the super-user is permitted to change
146 Modes may be absolute or symbolic.
147 An absolute mode is an octal number constructed from the sum of
148 one or more of the following values:
150 .Bl -tag -width 6n -compact -offset indent
153 Executable files with this bit set
154 will run with effective uid set to the uid of the file owner.
155 Directories with this bit set will force all files and
156 sub-directories created in them to be owned by the directory owner
157 and not by the uid of the creating process, if the underlying file
158 system supports this feature: see
166 Executable files with this bit set
167 will run with effective gid set to the gid of the file owner.
177 Allow write by owner.
179 For files, allow execution by owner.
180 For directories, allow the owner to
181 search in the directory.
183 Allow read by group members.
185 Allow write by group members.
187 For files, allow execution by group members.
188 For directories, allow
189 group members to search in the directory.
191 Allow read by others.
193 Allow write by others.
195 For files, allow execution by others.
196 For directories allow others to
197 search in the directory.
200 For example, the absolute mode that permits read, write and execute by
201 the owner, read and execute by group members, read and execute by
202 others, and no set-uid or set-gid behaviour is 755
203 (400+200+100+040+010+004+001).
205 The symbolic mode is described by the following grammar:
206 .Bd -literal -offset indent
207 mode ::= clause [, clause ...]
208 clause ::= [who ...] [action ...] action
209 action ::= op [perm ...]
210 who ::= a | u | g | o
212 perm ::= r | s | t | w | x | X | u | g | o
217 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
218 of the mode bits, respectively.
221 symbol ``a'' is equivalent to ``ugo''.
225 symbols represent the portions of the mode bits as follows:
227 .Bl -tag -width Ds -compact -offset indent
231 The set-user-ID-on-execution and set-group-ID-on-execution bits.
237 The execute/search bits.
239 The execute/search bits if the file is a directory or any of the
240 execute/search bits are set in the original (unmodified) mode.
243 symbol ``X'' are only meaningful in conjunction with the
245 symbol ``+'', and are ignored in all other cases.
247 The user permission bits in the original mode of the file.
249 The group permission bits in the original mode of the file.
251 The other permission bits in the original mode of the file.
256 symbols represent the operation performed, as follows:
259 If no value is supplied for
261 the ``+'' operation has no effect.
262 If no value is supplied for
264 each permission bit specified in
266 for which the corresponding bit in the file mode creation mask
270 Otherwise, the mode bits represented by the specified
276 If no value is supplied for
278 the ``\-'' operation has no effect.
279 If no value is supplied for
281 each permission bit specified in
283 for which the corresponding bit in the file mode creation mask
285 Otherwise, the mode bits represented by the specified
291 The mode bits specified by the
293 value are cleared, or, if no
295 value is specified, the owner, group
296 and other mode bits are cleared.
297 Then, if no value is supplied for
299 each permission bit specified in
301 for which the corresponding bit in the file mode creation mask
303 Otherwise, the mode bits represented by the specified
312 specifies one or more operations to be performed on the mode
313 bits, and each operation is applied to the mode bits in the
316 Operations upon the other permissions only (specified by the symbol
317 ``o'' by itself), in combination with the
319 symbols ``s'' or ``t'', are ignored.
321 The ``w'' permission on directories will permit file creation, relocation,
322 and copy into that directory.
323 Files created within the directory itself will inherit its group ID.
324 .Sh EXAMPLES OF VALID MODES
325 .Bl -tag -width "u=rwx,go=u-w" -compact
327 make a file readable by anyone and writable by the owner only.
330 deny write permission to group and others.
333 set the read and write permissions to the usual defaults, but
334 retain any execute permissions that are currently set.
337 make a directory or file searchable/executable by everyone if it is
338 already searchable/executable by anyone.
343 make a file readable/executable by everyone and writable by the owner only.
346 clear all mode bits for group and others.
349 set the group bits equal to the user bits, but clear the group write bit.
351 .Sh ACL MANIPULATION OPTIONS
352 ACLs are manipulated using extensions to the symbolic mode
353 grammar. Each file has one ACL, containing an ordered list of entries.
354 Each entry refers to a user or group, and grants or denies a set of
356 In cases where a user and a group exist with the same name, the
357 user/group name can be prefixed with "user:" or "group:" in order to
358 specify the type of name.
360 If the user or group name contains spaces you can use ':' as the delimiter
361 between name and permission.
363 The following permissions are applicable to all filesystem objects:
364 .Bl -tag -width 6n -compact -offset indent
366 Delete the item. Deletion may be granted by either this permission
367 on an object or the delete_child right on the containing directory.
369 Read an object's basic attributes. This is implicitly granted if
370 the object can be looked up and not explicitly denied.
372 Write an object's basic attributes.
374 Read extended attributes.
376 Write extended attributes.
378 Read an object's extended security information (ACL).
380 Write an object's security information (ownership, mode, ACL).
382 Change an object's ownership.
385 The following permissions are applicable to directories:
386 .Bl -tag -width 6n -compact -offset indent
390 Look up files by name.
396 Delete a contained object. See the file delete permission above.
399 The following permissions are applicable to non-directory filesystem objects:
400 .Bl -tag -width 6n -compact -offset indent
406 Open for writing, but in a fashion that only allows writes into areas of
407 the file not previously written.
409 Execute the file as a script or program.
412 ACL inheritance is controlled with the following permissions words, which
413 may only be applied to directories:
414 .Bl -tag -width 6n -compact -offset indent
417 .It directory_inherit
418 Inherit to directories.
420 This flag is only relevant to entries inherited by subdirectories; it
421 causes the directory_inherit flag to be cleared in the entry that is
422 inherited, preventing further nested subdirectories from also
423 inheriting the entry.
425 The entry is inherited by created items but not considered when processing
429 The ACL manipulation options are as follows:
432 The +a mode parses a new ACL entry from the next argument on
433 the commandline and inserts it into the canonical location in the
434 ACL. If the supplied entry refers to an identity already listed, the
435 two entries are combined.
439 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
440 # chmod +a "admin allow write" file1
442 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
445 # chmod +a "guest deny read" file1
447 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
451 # chmod +a "admin allow delete" file1
453 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
456 2: admin allow write,delete
457 # chmod +a "User 1:allow:read" file
459 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
463 3: admin allow write,delete
465 The +a mode strives to maintain correct canonical form for the ACL.
471 By default, chmod adds entries to the top of the local deny and local
472 allow lists. Inherited entries are added by using the +ai mode.
476 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
479 2: admin allow write,delete
480 3: juser inherited deny delete
481 4: admin inherited allow delete
482 5: backup inherited deny read
483 6: admin inherited allow write-security
484 # chmod +ai "others allow read" file1
486 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
489 2: admin allow write,delete
490 3: juser inherited deny delete
491 4: others inherited allow read
492 5: admin inherited allow delete
493 6: backup inherited deny read
494 7: admin inherited allow write-security
496 When a specific ordering is required, the exact location at which an
497 entry will be inserted is specified with the +a# mode.
501 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
505 # chmod +a# 2 "others deny read" file1
507 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
513 The +ai# mode may be used to insert inherited entries at a specific
514 location. Note that these modes allow non-canonical ACL ordering to
517 The -a mode is used to delete ACL entries. All entries exactly
518 matching the supplied entry will be deleted. If the entry lists a
519 subset of rights granted by an entry, only the rights listed are
520 removed. Entries may also be deleted by index using the -a# mode.
524 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
527 2: admin allow write,delete
530 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
532 1: admin allow write,delete
533 # chmod -a "admin allow write" file1
535 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
537 1: admin allow delete
539 Inheritance is not considered when processing the -a mode; rights and
540 entries will be removed regardless of their inherited state.
542 If the user or group name contains spaces you can use ':' as the delimiter
545 # chmod +a "User 1:allow:read" file
547 Individual entries are rewritten using the =a# mode.
551 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
553 1: admin allow delete
554 # chmod =a# 1 "admin allow write,chown"
556 -rw-r--r--+ 1 juser wheel 0 Apr 28 14:06 file1
558 1: admin allow write,chown
560 This mode may not be used to add new entries.
562 Reads the ACL information from stdin, as a sequential list
563 of ACEs, separated by newlines. If the information parses correctly,
564 the existing information is replaced.
566 Returns false if any of the named files have ACLs in non-canonical order.
568 Removes the 'inherited' bit from all entries in the named file(s) ACLs.
570 Removes all inherited entries from the named file(s) ACL(s).
572 Removes the ACL from the named file(s).
577 option is non-standard and its use in scripts is not recommended.
593 utility is expected to be
595 compatible with the exception of the
599 which is not included in that standard.