9070 Remove wanboot from gate
[unleashed.git] / usr / src / man / man1 / chmod.1
blob7aaa33d0128de727523a0fcdc33cfdafd50ca42f
1 '\" te
2 .\" Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
3 .\" Copyright 1989 AT&T.
4 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
5 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at  http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
8 .\" are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical
9 .\" and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
10 .\"  This notice shall appear on any product containing this material.
11 .\" 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.
12 .\" 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.
13 .\" 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]
14 .TH CHMOD 1 "Nov 24, 2014"
15 .SH NAME
16 chmod \- change the permissions mode of a file
17 .SH SYNOPSIS
18 .LP
19 .nf
20 \fBchmod\fR [\fB-fR\fR] \fIabsolute-mode\fR \fIfile\fR ...
21 .fi
23 .LP
24 .nf
25 \fBchmod\fR [\fB-fR\fR] \fIsymbolic-mode-list\fR \fIfile\fR ...
26 .fi
28 .LP
29 .nf
30 \fBchmod\fR [\fB-fR\fR] \fIacl_operation\fR \fIfile\fR ...
31 .fi
33 .LP
34 .nf
35 \fBchmod\fR [\fB-fR\fR] [\fB-@\fR \fInamed_attribute\fR]...\fIattribute_specification_list\fR \fIfile\fR ...
36 .fi
38 .SH DESCRIPTION
39 .LP
40 The \fBchmod\fR utility changes or assigns the mode of a file.
41 .sp
42 .LP
43 \fBchmod\fR can also be used to modify Access Control Lists (ACLs) on files and
44 directories, and to modify boolean read-write system attributes on regular
45 files, directories, and opaque extended attribute files.
46 .SS "Absolute Mode"
47 .LP
48 An absolute mode command line has the following format:
49 .sp
50 .LP
51 \fBchmod\fR [\fIoptions\fR] \fIabsolute-mode\fR \fIfile\fR ...
52 .sp
53 .LP
54 where \fIabsolute-mode\fR is specified using octal numbers \fInnnn\fR defined
55 as follows:
56 .sp
57 .ne 2
58 .na
59 \fB\fIn\fR\fR
60 .ad
61 .RS 5n
62 a number from \fB0\fR to \fB7\fR. An absolute mode is constructed from the OR
63 of any of the following modes:
64 .sp
65 .ne 2
66 .na
67 \fB\fB4000\fR\fR
68 .ad
69 .RS 12n
70 Set user \fBID\fR on execution.
71 .RE
73 .sp
74 .ne 2
75 .na
76 \fB\fB20\fR\fI\|#\|\fR\fB0\fR\fR
77 .ad
78 .RS 12n
79 Set group \fBID\fR on execution if \fI#\fR is \fB7\fR, \fB5\fR, \fB3\fR, or
80 \fB1\fR.
81 .sp
82 Enable mandatory locking if \fI#\fR is \fB6\fR, \fB4\fR, \fB2\fR, or \fB0\fR.
83 .sp
84 For directories, files are created with BSD semantics for propagation of the
85 group ID. With this option, files and subdirectories created in the directory
86 inherit the group ID of the directory, rather than of the current process. For
87 directories, the set-gid bit can only be set or cleared by using symbolic mode.
88 .RE
90 .sp
91 .ne 2
92 .na
93 \fB\fB1000\fR\fR
94 .ad
95 .RS 12n
96 Turn on sticky bit. See \fBchmod\fR(2).
97 .RE
99 .sp
100 .ne 2
102 \fB\fB0400\fR\fR
104 .RS 12n
105 Allow read by owner.
109 .ne 2
111 \fB\fB0200\fR\fR
113 .RS 12n
114 Allow write by owner.
118 .ne 2
120 \fB\fB0100\fR\fR
122 .RS 12n
123 Allow execute (search in directory) by owner.
127 .ne 2
129 \fB\fB0700\fR\fR
131 .RS 12n
132 Allow read, write, and execute (search) by owner.
136 .ne 2
138 \fB\fB0040\fR\fR
140 .RS 12n
141 Allow read by group.
145 .ne 2
147 \fB\fB0020\fR\fR
149 .RS 12n
150 Allow write by group.
154 .ne 2
156 \fB\fB0010\fR\fR
158 .RS 12n
159 Allow execute (search in directory) by group.
163 .ne 2
165 \fB\fB0070\fR\fR
167 .RS 12n
168 Allow read, write, and execute (search) by group.
172 .ne 2
174 \fB\fB0004\fR\fR
176 .RS 12n
177 Allow read by others.
181 .ne 2
183 \fB\fB0002\fR\fR
185 .RS 12n
186 Allow write by others.
190 .ne 2
192 \fB\fB0001\fR\fR
194 .RS 12n
195 Allow execute (search in directory) by others.
199 .ne 2
201 \fB\fB0007\fR\fR
203 .RS 12n
204 Allow read, write, and execute (search) by others.
211 For directories, the \fBsetgid\fR bit cannot be set (or cleared) in absolute
212 mode; it must be set (or cleared) in symbolic mode using \fBg+s\fR (or
213 \fBg-s\fR).
214 .SS "Symbolic Mode"
216 A symbolic mode command line has the following format:
219 \fBchmod\fR [\fIoptions\fR] \fIsymbolic-mode-list\fR \fIfile\fR ...
222 where \fIsymbolic-mode-list\fR is a comma-separated list (with no intervening
223 white space) of symbolic mode expressions of the form:
226 [\fBwho\fR] \fIoperator\fR [\fIpermissions\fR]
229 Operations are performed in the order given. Multiple \fIpermissions\fR letters
230 following a single operator cause the corresponding operations to be performed
231 simultaneously.
233 .ne 2
235 \fB\fBwho\fR\fR
237 .RS 14n
238 zero or more of the characters \fBu\fR, \fBg\fR, \fBo\fR, and \fBa\fR
239 specifying whose permissions are to be changed or assigned:
241 .ne 2
243 \fB\fBu\fR\fR
245 .RS 5n
246 user's permissions
250 .ne 2
252 \fB\fBg\fR\fR
254 .RS 5n
255 group's permissions
259 .ne 2
261 \fB\fBo\fR\fR
263 .RS 5n
264 others' permissions
268 .ne 2
270 \fB\fBa\fR\fR
272 .RS 5n
273 all permissions (user, group, and other)
276 If \fBwho\fR is omitted, it defaults to \fBa\fR, but the setting of the file
277 mode creation mask (see \fBumask\fR in \fBsh\fR(1) or \fBcsh\fR(1) for more
278 information) is taken into account. When \fBwho\fR is omitted, \fBchmod\fR does
279 not override the restrictions of your user mask.
283 .ne 2
285 \fB\fIoperator\fR\fR
287 .RS 14n
288 either \fB+\fR, \fB\(mi\fR, or \fB=\fR, signifying how permissions are to be
289 changed:
291 .ne 2
293 \fB\fB+\fR\fR
295 .RS 8n
296 Add permissions.
298 If \fIpermissions\fR are omitted, nothing is added.
300 If \fBwho\fR is omitted, add the file mode bits represented by
301 \fIpermissions\fR, \fIexcept\fR for the those with corresponding bits in the
302 file mode creation mask.
304 If \fBwho\fR is present, add the file mode bits represented by the
305 \fIpermissions\fR.
309 .ne 2
311 \fB\fB\(mi\fR\fR
313 .RS 8n
314 Take away permissions.
316 If \fIpermissions\fR are omitted, do nothing.
318 If \fBwho\fR is omitted, clear the file mode bits represented by
319 \fIpermissions\fR, \fIexcept\fR for those with corresponding bits in the file
320 mode creation mask.
322 If \fBwho\fR is present, clear the file mode bits represented by
323 \fIpermissions\fR.
327 .ne 2
329 \fB\fB=\fR\fR
331 .RS 8n
332 Assign permissions absolutely.
334 If \fBwho\fR is omitted, clear all file mode bits; if \fBwho\fR is present,
335 clear the file mode bits represented by \fBwho\fR.
337 If \fIpermissions\fR are omitted, do nothing else.
339 If \fBwho\fR is omitted, add the file mode bits represented by
340 \fIpermissions\fR, \fIexcept\fR for the those with corresponding bits in the
341 file mode creation mask.
343 If \fBwho\fR is present, add the file mode bits represented by
344 \fIpermissions\fR.
347 Unlike other symbolic operations, \fB=\fR has an absolute effect in that it
348 resets all other bits represented by \fBwho\fR. Omitting \fIpermissions\fR is
349 useful only with \fB=\fR to take away all permissions.
353 .ne 2
355 \fB\fIpermission\fR\fR
357 .RS 14n
358 any compatible combination of the following letters:
360 .ne 2
362 \fB\fBl\fR\fR
364 .RS 9n
365 mandatory locking
369 .ne 2
371 \fB\fBr\fR\fR
373 .RS 9n
374 read permission
378 .ne 2
380 \fB\fBs\fR\fR
382 .RS 9n
383 user or group set-ID
387 .ne 2
389 \fB\fBt\fR\fR
391 .RS 9n
392 sticky bit
396 .ne 2
398 \fB\fBw\fR\fR
400 .RS 9n
401 write permission
405 .ne 2
407 \fB\fBx\fR\fR
409 .RS 9n
410 execute permission
414 .ne 2
416 \fB\fBX\fR\fR
418 .RS 9n
419 execute permission if the file is a directory or if there is execute permission
420 for one of the other user classes
424 .ne 2
426 \fB\fBu\fR,\fBg\fR,\fBo\fR\fR
428 .RS 9n
429 indicate that \fIpermission\fR is to be taken from the current user, group or
430 other mode respectively.
433 Permissions to a file can vary depending on your user identification number
434 (UID) or group identification number (GID). Permissions are described in three
435 sequences each having three characters:
440 l l l
441 l l l .
442 User    Group   Other
443 rwx     rwx     rwx
446 This example (user, group, and others all have permission to read, write, and
447 execute a given file) demonstrates two categories for granting permissions: the
448 access class and the permissions themselves.
450 The letter \fBs\fR is only meaningful with \fBu\fR or \fBg\fR, and \fBt\fR only
451 works with \fBu\fR.
453 Mandatory file and record locking (\fBl\fR) refers to a file's ability to have
454 its reading or writing permissions locked while a program is accessing that
455 file.
457 In a directory which has the set-group-ID bit set (reflected as either
458 \fB-----s---\fR or \fB-----l---\fR in the output of \fB\&'ls -ld'\fR), files
459 and subdirectories are created with the group-ID of the parent directory\(emnot
460 that of current process.
462 It is not possible to permit group execution and enable a file to be locked on
463 execution at the same time. In addition, it is not possible to turn on the
464 set-group-ID bit and enable a file to be locked on execution at the same time.
465 The following examples, therefore, are invalid and elicit error messages:
467 .in +2
469 chmod g+x,+l \fIfile\fR
470 chmod g+s,+l \fIfile\fR
472 .in -2
475 Only the owner of a file or directory (or the super-user) can change that
476 file's or directory's mode. Only the super-user can set the sticky bit on a
477 non-directory file. If you are not super-user, \fBchmod\fR masks the sticky-bit
478 but does not return an error. In order to turn on a file's set-group-ID bit,
479 your own group ID must correspond to the file's and group execution must be
480 set.
483 .SS "ACL Operation"
485 An ACL Operation command line has the following format:
487 .in +2
489 chmod [\fIoptions\fR] A[\fInumber\fR]- \fIfile\fR ...
490 chmod [\fIoptions\fR] A-\fIacl_specification\fR \fIfile\fR ...
491 chmod [\fIoptions\fR] A[\fIindex\fR]{+|=}\fIacl_specification\fR \fIfile\fR ...
493 .in -2
498 Where \fIacl_specification\fR is a comma-separated list (with no intervening
499 white space) of an ACL specification of the form:
501 .ne 2
503 \fB\fBA[\fIindex\fR]+\fIacl_specification\fR\fR\fR
505 .RS 30n
506 Prepends the access control entries (ACE) specified in \fIacl_specification\fR
507 to the beginning of the file's ACL. Depending on the file system, the ACL can
508 be reordered when applied to the file. If "optional" number is specified then
509 new ACEs are inserted before specified number.
513 .ne 2
515 \fB\fBA-\fR\fR
517 .RS 30n
518 Removes all ACEs for current ACL on file and replaces current ACL with new ACL
519 that represents only the current mode of the file.
523 .ne 2
525 \fB\fBA\fIindex\fR\fR-\fR
527 .RS 30n
528 Removes ACE specified by \fIindex\fR number.
532 .ne 2
534 \fB\fBA-\fIacl_specification\fR\fR\fR
538 \fB\fR
540 .RS 30n
541 Removes ACEs specified by \fIacl_specification\fR, if they exist in current
542 file's ACL.
546 .ne 2
548 \fB\fBA=\fIacl_specification\fR\fR\fR
550 .RS 30n
551 Replaces a files entire ACL with \fIacl_specification\fR.
555 .ne 2
557 \fB\fBA[\fIindex\fR]=\fIacl_specification\fR\fR\fR
559 .RS 30n
560 Replaces ACEs starting at a specific index number in the current ACL on the
561 file. If multiple ACEs are specified, then each subsequent ACE in
562 \fIacl_specification\fR replaces the corresponding ACE in the current ACL.
567 \fBPOSIX-draft ACL Specification (as supported by UFS)\fR
570 POSIX-draft ACLs (as supported by UFS) are specified as colon (\fB:\fR)
571 separated fields of the following.
573 .ne 2
575 \fBuser::perms\fR
577 .sp .6
578 .RS 4n
579 File owner permissions.
583 .ne 2
585 \fBuser:\fIusername\fR:perms\fR
587 .sp .6
588 .RS 4n
589 Permissions for a specific user.
593 .ne 2
595 \fBgroup::perms\fR
597 .sp .6
598 .RS 4n
599 File group owner permissions.
603 .ne 2
605 \fBgroup:\fIgroupname:\fRperms\fR
607 .sp .6
608 .RS 4n
609 Permissions for a specific group.
613 .ne 2
615 \fBother::perms\fR
617 .sp .6
618 .RS 4n
619 Permissions for user other than the file owner or members of file group owner.
623 .ne 2
625 \fBmask:perms\fR
627 .sp .6
628 .RS 4n
629 The ACL mask. The mask entry specifies the maximum permissions allowed for user
630 (other than that the owner) and for groups.
634 .ne 2
636 \fBdefault:user::perms\fR
638 .sp .6
639 .RS 4n
640 Default file owner permissions.
644 .ne 2
646 \fBdefault:user:\fIusername\fR:perms\fR
648 .sp .6
649 .RS 4n
650 Default permissions for a specific user.
654 .ne 2
656 \fBdefault:group::perms\fR
658 .sp .6
659 .RS 4n
660 Default file group owner permissions.
664 .ne 2
666 \fBdefault:group:\fIgroupname\fR:perms\fR
668 .sp .6
669 .RS 4n
670 Default permissions for a specific group.
674 .ne 2
676 \fBdefault:other:perms\fR
678 .sp .6
679 .RS 4n
680 Default permissions for user other than the file owner or members of the file
681 group owner.
685 .ne 2
687 \fBdefault:mask:perms\fR
689 .sp .6
690 .RS 4n
691 Default ACL mask.
696 The above specification allows for ACLs to be specified such as:
698 .in +2
700 user:tom:rw-,mask:rwx,group:staff:r-x
702 .in -2
707 \fBNFSv4 ACL Specification (as supported by NFSv4 and ZFS)\fR
710 NFSv4 ACLs provide richer ACL semantics. They provide both allow and deny
711 entries, finer grained permissions, and enhanced inheritance control.
714 NFSv4 ACLs are specified as colon (\fB:\fR) separated fields of the following.
716 .ne 2
718 \fBowner@:<perms>[:inheritance flags]:<allow|deny>\fR
720 .sp .6
721 .RS 4n
722 Permissions for file owner.
726 .ne 2
728 \fBgroup@:<perms>[:inheritance flags]:<allow|deny>\fR
730 .sp .6
731 .RS 4n
732 Permissions for file group owner.
736 .ne 2
738 \fBeveryone@:<perms>[:inheritance flags]:<allow|deny>\fR
740 .sp .6
741 .RS 4n
742 Permissions for everyone, including file owner and group owner.
746 .ne 2
748 \fBuser:<username>:<perms>[:inheritance flags]:<allow|deny>\fR
750 .sp .6
751 .RS 4n
752 Permissions for a specific user.
756 .ne 2
758 \fBusersid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
760 .sp .6
761 .RS 4n
762 Permissions for a specific user, but user is specified by SID.
766 .ne 2
768 \fBgroup:<groupname>:<perms>[:inheritance flags]:<allow|deny>\fR
770 .sp .6
771 .RS 4n
772 Permissions for a specific group.
776 .ne 2
778 \fBgroupsid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
780 .sp .6
781 .RS 4n
782 Permissions for a specific group, but group is specified by SID.
786 .ne 2
788 \fBsid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
790 .sp .6
791 .RS 4n
792 Permissions for a specific SID, but it doesn't matter if it is a user or a
793 group.
798 Permissions can be specified in three different \fBchmod\fR ACL formats:
799 verbose, compact, or positional. The verbose format uses words to indicate that
800 the permissions are separated with a forward slash (\fB/\fR) character. Compact
801 format uses the permission letters and positional format uses the permission
802 letters or the hyphen (\fB-\fR) to identify no permissions.
805 The permissions for verbose mode and their abbreviated form in parentheses for
806 compact and positional mode are described as follows:
808 .ne 2
810 \fBread_data (\fBr\fR)\fR
812 .RS 24n
813 Permission to read the data of a file.
817 .ne 2
819 \fBlist_directory (\fBr\fR)\fR
821 .RS 24n
822 Permission to list the contents of a directory.
826 .ne 2
828 \fBwrite_data (\fBw\fR)\fR
830 .RS 24n
831 Permission to modify a file's data. anywhere in the file's offset range.
835 .ne 2
837 \fBadd_file (\fBw\fR)\fR
839 .RS 24n
840 Permission to add a new file to a directory.
844 .ne 2
846 \fBappend_data (\fBp\fR)\fR
848 .RS 24n
849 The ability to modify a file's data, but only starting at EOF.
851 Currently, this permission is not supported.
855 .ne 2
857 \fBadd_subdirectory (\fBp\fR)\fR
859 .RS 24n
860 Permission to create a subdirectory to a directory.
864 .ne 2
866 \fBread_xattr (\fBR\fR)\fR
868 .RS 24n
869 Ability to read the extended attributes of a file.
873 .ne 2
875 \fBwrite_xattr (\fBW\fR)\fR
877 .RS 24n
878 Ability to create extended attributes or write to the extended attribute
879 directory.
883 .ne 2
885 \fBexecute (\fBx\fR)\fR
887 .RS 24n
888 Permission to execute a file.
892 .ne 2
894 \fBread_attributes (\fBa\fR)\fR
896 .RS 24n
897 The ability to read basic attributes (non-ACLs) of a file.
901 .ne 2
903 \fBwrite_attributes (\fBA\fR)\fR
905 .RS 24n
906 Permission to change the times associated with a file or directory to an
907 arbitrary value.
911 .ne 2
913 \fBdelete (\fBd\fR)\fR
915 .RS 24n
916 Permission to delete a file.
920 .ne 2
922 \fBdelete_child (\fBD\fR)\fR
924 .RS 24n
925 Permission to delete a file within a directory.
929 .ne 2
931 \fBread_acl (\fBc\fR)\fR
933 .RS 24n
934 Permission to read the ACL of a file.
938 .ne 2
940 \fBwrite_acl (\fBC\fR)\fR
942 .RS 24n
943 Permission to write the ACL of a file.
947 .ne 2
949 \fBwrite_owner (\fBo\fR)\fR
951 .RS 24n
952 Permission to change the owner of a file.
956 .ne 2
958 \fBsynchronize (\fBs\fR)\fR
960 .RS 24n
961 Permission to access file locally at server with synchronize reads and writes.
963 Currently, this permission is not supported.
968 Using the compact ACL format, permissions are specified by using 14 unique
969 letters to indicate permissions.
972 Using the positional ACL format, permissions are specified as positional
973 arguments similar to the \fBls\fR \fB-V\fR format. The hyphen (\fB-\fR), which
974 indicates that no permission is granted at that position, can be omitted and
975 only the required letters have to be specified.
978 The letters above are listed in the order they would be specified in positional
979 notation.
982 Permissions can be specified with these letters in the following way:
984 .in +2
986 rwx--D--------
988 .in -2
993 The hyphens can be removed to compact the string as follows:
995 .in +2
997 rwxD
999 .in -2
1004 Several special permission sets or aliases are also supported. The following
1005 permission sets are used the same way that verbose permissions are specified.
1007 .ne 2
1009 \fB\fBfull_set\fR\fR
1011 .RS 14n
1012 All permissions.
1016 .ne 2
1018 \fB\fBmodify_set\fR\fR
1020 .RS 14n
1021 All permissions except \fBwrite_acl\fR and \fBwrite_owner\fR.
1025 .ne 2
1027 \fB\fBread_set\fR\fR
1029 .RS 14n
1030 \fBread_data, read_acl, read_attributes,\fR and \fBread_xattr\fR.
1034 .ne 2
1036 \fB\fBwrite_set\fR\fR
1038 .RS 14n
1039 \fBwrite_data, append_data, write_attributes\fR, and \fBwrite_xattr\fR
1044 The optional inheritance flags can be specified in the three formats. The first
1045 format uses words to indicate the various inheritance flags separated with a
1046 forward slash (\fB/\fR) character.
1048 .ne 2
1050 \fBfile_inherit (\fBf\fR)\fR
1052 .RS 20n
1053 Inherit to all newly created files.
1057 .ne 2
1059 \fBdir_inherit (\fBd\fR)\fR
1061 .RS 20n
1062 Inherit to all newly created directories.
1066 .ne 2
1068 \fBinherit_only (\fBi\fR)\fR
1070 .RS 20n
1071 When placed on a directory, do not apply to the directory, only to newly
1072 created files and directories. This flag requires that either
1073 \fBfile_inherit\fR and or \fBdir_inherit\fR is also specified.
1077 .ne 2
1079 \fBno_propagate (\fBn\fR)\fR
1081 .RS 20n
1082 Indicates that ACL entries should be inherited to objects in a directory, but
1083 inheritance should stop after descending one level. This flag is dependent upon
1084 either \fBfile_inherit\fR and or \fBdir_inherit\fR also being specified.
1088 .ne 2
1090 \fBsuccessful_access (\fBS\fR)\fR
1092 .RS 20n
1093 Indicates whether an alarm or audit record should be initiated upon successful
1094 accesses. Used with audit/alarm ACE types.
1098 .ne 2
1100 \fBfailed_access (\fBF\fR)\fR
1102 .RS 20n
1103 Indicates whether an alarm or audit record should be initiated when access
1104 fails. Used with audit/alarm ACE types.
1108 .ne 2
1110 \fBinherited (\fBI\fR)\fR
1112 .RS 20n
1113 ACE was inherited.
1118 The inheritance flags listed can also be specified in the compact format or as
1119 positional arguments similar to the \fBls\fR \fB-V\fR format. A hyphen
1120 character indicates that the inheritance flag at that position is not specified
1121 in the positional ACL format.
1124 The inheritance flags can be specified with these letters in any of the
1125 following equivalent ways.
1127 .in +2
1129 file_inherit/dir_inherit/no_propagate
1131 .in -2
1135 .in +2
1137 fd-n---
1139 .in -2
1143 .in +2
1147 .in -2
1152 With this inheritance model, an ACL entry can be specified such as:
1154 .in +2
1156 user:tom:read_data/write_data/read_attributes:file_inherit:allow
1157 user:fred:read_data:file_inherit/dir_inherit:deny
1158 user:bob:read_data:allow
1160 .in -2
1163 .SS "Attribute Operation"
1165 An attribute operation command line has the following format:
1167 .in +2
1169 chmod [\fIoptions\fR] \fIattribute_specification_list\fR \fIfile\fR ...
1171 .in -2
1176 where \fIattribute_specification_list\fR is the character \fBS\fR followed by a
1177 comma-separated list of one or more \fIattribute_specifications\fR. Each
1178 \fIattribute_specification\fR is of the form:
1180 .in +2
1182 [\fIoperator\fR]\fIattribute_specifier\fR
1184 .in -2
1189 An \fIoperator\fR is one of the following:
1191 .ne 2
1193 \fB\fB+\fR\fR
1195 .RS 5n
1196 Each attribute specified by the associated \fIattribute_specifier\fR is
1197 adjusted to match the value specified by the \fIattribute_specifier\fR.
1201 .ne 2
1203 \fB\fB-\fR\fR
1205 .RS 5n
1206 Each attribute specified by the associated \fIattribute_specifier\fR is
1207 adjusted to match the inverse of the value specified by the
1208 \fIattribute_specifier\fR.
1212 .ne 2
1214 \fB\fB=\fR\fR
1216 .RS 5n
1217 Each attribute specified by the associated \fIattribute_specifier\fR is
1218 adjusted to match the value specified by the \fIattribute_specifier\fR. Any
1219 boolean read-write extended system attributes associated with the current file
1220 that are not specified by \fIattribute_specifier\fR is cleared.
1225 If an \fIoperator\fR is not specified in an \fIattribute_specification\fR,
1226 \fBchmod\fR behaves as if \fB+\fR had been specified.
1229 An \fIattribute_specifier\fR takes one of the following forms:
1231 .ne 2
1233 \fB\fBa\fR\fR
1235 .sp .6
1236 .RS 4n
1237 Set all boolean read-write extended system attributes associated with the
1238 current file.
1242 .ne 2
1244 \fB\fBc[\fIcompact_attribute_list\fR]\fR\fR
1248 \fB\fBc'{'\fIcompact_attribute_list\fR'}'\fR\fR
1250 .sp .6
1251 .RS 4n
1252 Set each boolean read-write extended system attribute identified by
1253 \fIcompact_attribute_list\fR.
1257 .ne 2
1259 \fB\fBv[\fIverbose_attribute_setting\fR]\fR\fR
1263 \fB\fBv['{'\fIverbose_attribute_setting_list\fR'}']\fR\fR
1265 .sp .6
1266 .RS 4n
1267 Set each boolean read-write extended system attribute identified by
1268 \fIverbose_attribute_setting\fR.
1273 A \fIcompact_attribute_list\fR is a list of zero or more adjacent attribute
1274 abbreviation characters from  list of \fBAttribute Names and Abbreviation
1275 Characters\fR later in this section. An arbitrary number of hyphen (\fB-\fR)
1276 characters can be included in a \fIcompact_attribute_list\fR. These are
1277 ignored.
1280 A \fIverbose_attribute_setting\fR is an attribute name from the  list of
1281 \fBAttribute Names and Abbreviation Characters\fR later in this section,
1282 optionally, immediately preceded by \fBno\fR. If the attribute name is used
1283 without \fBno\fR, the attribute is set; otherwise the attribute is cleared.
1286 A \fIverbose_attribute_setting_list\fR is zero or more comma-separated
1287 \fIverbose_attribute_setting\fRs.
1290 Multiple operations specified for a file are accumulated and are all set for a
1291 file operand as a single attribute setting operation. If an attribute is
1292 specified more than once in an \fIattribute_specification_list\fR, the last
1293 specified operation is applied.
1296 The following is a list of \fBAttribute Names and Abbreviation Characters\fR:
1298 .ne 2
1300 \fB\fBAttribute Name\fR\fR
1302 .RS 18n
1303 \fBAbbreviation Character\fR
1307 .ne 2
1309 \fB\fBhidden\fR\fR
1311 .RS 18n
1312 \fBH\fR
1316 .ne 2
1318 \fB\fBsystem\fR\fR
1320 .RS 18n
1321 \fBS\fR
1325 .ne 2
1327 \fB\fBreadonly\fR\fR
1329 .RS 18n
1330 \fBR\fR
1334 .ne 2
1336 \fB\fBarchive\fR\fR
1338 .RS 18n
1339 \fBA\fR
1343 .ne 2
1345 \fB\fBnounlink\fR\fR
1347 .RS 18n
1348 \fBu\fR
1352 .ne 2
1354 \fB\fBimmutable\fR\fR
1356 .RS 18n
1357 \fBi\fR
1361 .ne 2
1363 \fB\fBappendonly\fR\fR
1365 .RS 18n
1366 \fBa\fR
1370 .ne 2
1372 \fB\fBnodump\fR\fR
1374 .RS 18n
1375 \fBd\fR
1379 .ne 2
1381 \fB\fBav_quarantined\fR\fR
1383 .RS 18n
1384 \fBq\fR
1388 .ne 2
1390 \fB\fBav_modified\fR\fR
1392 .RS 18n
1393 \fBm\fR
1397 .ne 2
1399 \fB\fBoffline\fR\fR
1401 .RS 18n
1402 \fBO\fR
1406 .ne 2
1408 \fB\fBsparse\fR\fR
1410 .RS 18n
1411 \fBs\fR
1414 .SH OPTIONS
1416 The following options are supported:
1418 .ne 2
1420 \fB\fB-f\fR\fR
1422 .RS 22n
1423 Force. \fBchmod\fR does not complain if it fails to change the mode of a file.
1427 .ne 2
1429 \fB\fB-R\fR\fR
1431 .RS 22n
1432 Recursively descend through directory arguments, setting the mode for each
1433 file. When symbolic links are encountered, the mode of the target file is
1434 changed, but no recursion takes place.
1438 .ne 2
1440 \fB\fB-@\fR \fInamed_attribute\fR\fR
1442 .RS 22n
1443 Perform the attribute operation on the named extended attribute file of each
1444 file operand instead of the file operand itself. If multiple \fB-@\fR
1445 operations are supplied, the attribute specification mode is applied to each of
1446 the named attribute files.
1448 A named attribute of \fB*\fR carries meaning to \fBchmod\fR, and is considered
1449 to mean all extended attribute files associated with a file operand. This does
1450 not refer to the special files \fB\&.\fR and \fB\&..\fR.
1452 A named attribute of \fB\&..\fR carries special meaning to \fBchmod\fR, and is
1453 considered to mean the file operand itself. This allows \fBchmod\fR, in a
1454 single call, to apply the attribute specification mode to the specified named
1455 attribute file of the file operand and the file operand itself.
1458 .SH OPERANDS
1460 The following operands are supported:
1462 .ne 2
1464 \fB\fIabsolute-mode\fR\fR
1468 \fB\fIsymbolic-mode-list\fR\fR
1470 .sp .6
1471 .RS 4n
1472 Represents the change to be made to the file mode bits of each file named by
1473 one of the \fIfile\fR operands. See \fBAbsolute Mode\fR and \fBSymbolic Mode\fR
1474 in the \fBDESCRIPTION\fR section of this manual page for more information.
1478 .ne 2
1480 \fB\fIacl_operation\fR\fR
1482 .sp .6
1483 .RS 4n
1484 Represents the modification to be performed on the file's ACL. See \fBACL
1485 Operation\fR in the \fBDESCRIPTION\fR section for more information.
1487 \fIacl_operation\fR is one of the following:
1489 .in +2
1491 \fBA[\fR\fInumber\fR\fB] -\fR
1492 \fBA-\fR\fIacl_specification\fR
1493 \fBA[\fR\fIindex\fR\fB]{+|=}\fR\fBacl_specification\fR
1495 .in -2
1501 .ne 2
1503 \fB\fIattribute_specification_list\fR\fR
1505 .sp .6
1506 .RS 4n
1507 Represents the modification to performed on the file's attributes. See
1508 Attribute Operation in the \fBDESCRIPTION\fR section of this manual page for
1509 more information.
1513 .ne 2
1515 \fB\fIfile\fR\fR
1517 .sp .6
1518 .RS 4n
1519 A path name of a file whose file mode bits are to be modified.
1522 .SH USAGE
1524 See \fBlargefile\fR(5) for the description of the behavior of \fBchmod\fR when
1525 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
1526 .SH EXAMPLES
1528 \fBExample 1 \fRDenying \fBexecute\fR Permission
1531 The following example denies execute permission to everyone:
1534 .in +2
1536 % chmod a-x \fIfile\fR
1538 .in -2
1542 \fBExample 2 \fRAllowing \fBread-only\fR Permission
1545 The following example allows only read permission to everyone:
1548 .in +2
1550 % chmod 444 \fIfile\fR
1552 .in -2
1556 \fBExample 3 \fRMaking a File \fBreadable\fR and \fBwritable\fR
1559 The following example makes a file readable and writable by the group and
1560 others:
1563 .in +2
1565 % chmod go+rw \fIfile\fR
1566 % chmod 066 \fIfile\fR
1568 .in -2
1572 \fBExample 4 \fRLocking a File From Access
1575 The following example locks a file from access:
1578 .in +2
1580 $ chmod +l \fIfile\fR
1582 .in -2
1586 \fBExample 5 \fRGranting \fBread\fR, \fBwrite\fR, \fBexecute\fR, and \fBset
1587 group-ID\fR Permission on a File
1590 The following example grants everyone read, write, and execute permissions on
1591 the file, and turns on the set group-ID:
1594 .in +2
1596 $ chmod a=rwx,g+s \fIfile\fR
1597 $ chmod 2777 \fIfile\fR
1599 .in -2
1603 \fBExample 6 \fRPrepending a New ACL Entry on a ZFS File
1606 The following example prepends a new ACL entry on a ZFS file.
1610 First, display the current ACL:
1613 .in +2
1615 $ ls -v file.3
1616 -rw-r--r--   1 marks    staff          0 Oct  9 15:49 file.3
1617       0:owner@:execute:deny
1618       1:owner@:read_data/write_data/append_data/write_xattr/
1619          write_attributes/write_acl/write_owner:allow
1620       2:group@:write_data/append_data/execute:deny
1621       3:group@:read_data:allow
1622       4:everyone@:write_data/append_data/write_xattr/execute/
1623         write_attributes/write_acl/write_owner:deny
1624       5:everyone@:read_data/read_xattr/read_attributes/read_acl/
1625          synchronize:allow
1627 .in -2
1632 Issue the following command:
1635 .in +2
1637 $ chmod A+user:lp:read_data:deny file.3
1639 .in -2
1644 Display the new ACL:
1647 .in +2
1649 $ ls -v file.3
1650 -rw-r--r--+  1 marks    staff          0 Oct  9 15:49 file.3
1651       0:user:lp:read_data:deny
1652       1:owner@:execute:deny
1653       2:owner@:read_data/write_data/append_data/write_xattr/
1654           write_attributes/write_acl/write_owner:allow
1655       3:group@:write_data/append_data/execute:deny
1656       4:group@:read_data:allow
1657       5:everyone@:write_data/append_data/write_xattr/execute/
1658           write_attributes/write_acl/write_owner:deny
1659       6:everyone@:read_data/read_xattr/read_attributes/read_acl/
1660           synchronize:allow
1662 .in -2
1666 \fBExample 7 \fRPrepending a New POSIX-draft ACL Entry on a UFS File
1669 The following example prepends a new POSIX-draft ACL entry on a UFS file.
1673 First, display the current ACL:
1676 .in +2
1678 $ ls -v file.2
1679 -rw-r--r--   1 marks    staff          0 Oct  9 15:52 file.2
1680       0:user::rw-
1681       1:group::r--           #effective:r--
1682       2:mask:r--
1683       3:other:r--
1685 .in -2
1690 Issue the following command:
1693 .in +2
1695 $ chmod A+user:lp:-wx file.2
1697 .in -2
1702 Display the new ACL:
1705 .in +2
1707 $ ls -v file.2
1708 -rw-r--r--+  1 marks    staff          0 Oct  9 15:52 file.2
1709       0:user::rw-
1710       1:user:lp:-wx          #effective:---
1711       2:group::r--           #effective:r--
1712       3:mask:r--
1713       4:other:r--
1715 .in -2
1719 \fBExample 8 \fRInserting an ACL Entry in a Specific Position on a ZFS file
1722 The following example inserts an ACL entry in a specific position on a ZFS file
1723 system. It also illustrates the compact ACL format.
1727 First, display the ACL to pick a location to insert a new ACE.
1730 .in +2
1732 % ls -V file.1
1733 -rw-r--r--+  1 root     root           0 Oct  6 12:16 file.1
1734      user:lp:rw------------:-------:allow
1735       owner@:--x-----------:-------:deny
1736       owner@:rw-p---A-W-Co-:-------:allow
1737       group@:-wxp----------:-------:deny
1738       group@:r-------------:-------:allow
1739    everyone@:-wxp---A-W-Co-:-------:deny
1740    everyone@:r-----a-R-c--s:-------:allow
1742 .in -2
1747 Next, insert a new entry in location 3.   This  causes  the  entries  that  are
1748 currently in position 3 - 6 to be pushed down.
1752 Issue the following command:
1755 .in +2
1757 $ chmod A3+user:marks:r:deny file.1
1759 .in -2
1764 Display the new ACL:
1767 .in +2
1769 $ ls -V file.1
1770 -rw-r--r--+  1 root     staff          0 Feb  3 14:13 file.1
1771      user:lp:rw------------:-------:allow
1772       owner@:--x-----------:-------:deny
1773       owner@:rw-p---A-W-Co-:-------:allow
1774   user:marks:r-------------:-------:deny
1775       group@:-wxp----------:-------:deny
1776       group@:r-------------:-------:allow
1777    everyone@:-wxp---A-W-Co-:-------:deny
1778    everyone@:r-----a-R-c--s:-------:allow
1780 .in -2
1784 \fBExample 9 \fRInserting a POSIX-draft ACL in a Specific Position on a UFS
1785 File
1788 The file system reorders ACLs when they are stored in the file system. The
1789 following example illustrates this behavior.
1792 .in +2
1794 $ ls -v file.1
1795 -rw-r--r--+  1 root     root           0 Sep 29 16:10 file.1
1796       0:user::rw-
1797       1:user:lp:rw-          #effective:r--
1798       2:group::r--           #effective:r--
1799       3:mask:r--
1800       4:other:r--
1802 .in -2
1807 Now, insert an entry at index position 3.  The command works, but the file
1808 system reorders the ACL.
1811 .in +2
1813 $ chmod A3+user:marks:rw- file.1
1814 $ ls -v file.1
1815 -rw-r--r--+  1 root     root           0 Sep 29 16:10 file.1
1816       0:user::rw-
1817       1:user:lp:rw-           #effective:r--
1818       2:user:marks:rw-        #effective:r--
1819       3:group::r--            #effective:r--
1820       4:mask:r--
1821       5:other:r--
1823 .in -2
1828 Rather than inserting the ACL entry in position 3 as requested, it actually
1829 ends up in position 2.
1832 \fBExample 10 \fRRemoving an ACL Entry on a ZFS File
1835 The following example removes the \fBlp\fR entry from an ACL:
1838 .in +2
1840 $ ls -v file.3
1841 -rw-r--r--+  1 marks    staff          0 Oct  9 15:49 file.3
1842       0:user:lp:read_data:deny
1843       1:owner@:execute:deny
1844       2:owner@:read_data/write_data/append_data/write_xattr/
1845          write_attributes/write_acl/write_owner:allow
1846       3:group@:write_data/append_data/execute:deny
1847       4:group@:read_data:allow
1848       5:everyone@:write_data/append_data/write_xattr/execute/
1849          write_attributes/write_acl/write_owner:deny
1850       6:everyone@:read_data/read_xattr/read_attributes/read_acl/
1851          synchronize:allow
1853 .in -2
1857 .in +2
1859 $ chmod A-user:lp:read_data:deny file.3
1860 $ ls -v file.3
1861 -rw-r--r--   1 marks    staff          0 Oct  9 15:49 file.3
1862       0:owner@:execute:deny
1863       1:owner@:read_data/write_data/append_data/write_xattr/
1864          write_attributes/write_acl/write_owner:allow
1865       2:group@:write_data/append_data/execute:deny
1866       3:group@:read_data:allow
1867       4:everyone@:write_data/append_data/write_xattr/execute/
1868          write_attributes/write_acl/write_owner:deny
1869       5:everyone@:read_data/read_xattr/read_attributes/read_acl/
1870          synchronize:allow
1872 .in -2
1876 \fBExample 11 \fRRemoving a POSIX-draft ACL on a UFS File
1879 The following example removes the \fBlp\fR entry from an ACL:
1882 .in +2
1884 $ ls -v file.2
1885 -rw-r--r--+  1 marks    staff          0 Oct  9 15:52 file.2
1886       0:user::rw-
1887       1:user:lp:-wx           #effective:---
1888       2:group::r--            #effective:r--
1889       3:mask:r--
1890       4:other:r--
1892 .in -2
1896 .in +2
1898 $ chmod A-user:lp:-wx file.2
1899 $ ls -v file.2
1900 -rw-r--r--   1 marks    staff          0 Oct  9 15:52 file.2
1901       0:user::rw-
1902       1:group::r--            #effective:r--
1903       2:mask:r--
1904       3:other:r--
1906 .in -2
1910 \fBExample 12 \fRRemoving a Specific ACL Entry by Index Number on a ZFS File
1913 Consider the following ACL:
1916 .in +2
1918 $ ls -v file
1919     0:group:staff:read_data/write_data/execute/read_acl:allow
1920     1:user:bin:read_data:deny
1921     2:user:bin:read_data:allow
1922     3:owner@:write_data/append_data:deny
1923     4:owner@:read_data/write_xattr/execute/write_attributes/write_acl
1924         /write_owner:allow
1925     5:group@:write_data/append_data:deny
1926     6:group@:read_data/execute:allow
1927     7:everyone@:write_data/append_data/write_xattr/write_attributes
1928         /write_acl/write_owner:deny
1929     8:everyone@:read_data/read_xattr/execute/read_attributes/read_acl
1930         /synchronize:allow
1932 .in -2
1937 Remove the second user entry for bin.
1940 .in +2
1942 $ chmod A2- file
1943 $ ls -v file
1944     0:group:staff:read_data/write_data/execute/read_acl:allow
1945     1:user:bin:read_data:deny
1946     2:owner@:write_data/append_data:deny
1947     3:owner@:read_data/write_xattr/execute/write_attributes/write_acl
1948        /write_owner:allow
1949     4:group@:write_data/append_data:deny
1950     5:group@:read_data/execute:allow
1951     6:everyone@:write_data/append_data/write_xattr/write_attributes
1952        /write_acl/write_owner:deny
1953     7:everyone@:read_data/read_xattr/execute/read_attributes/read_acl
1954        /synchronize:allow
1956 .in -2
1960 \fBExample 13 \fRRemoving a Specific POSIX-draft ACL Entry on a UFS File
1963 The following example removes the lp entry by index number from the following
1964 ACL:
1967 .in +2
1969 $ ls -v file.1
1970 -rw-r--r--+  1 root     root           0 Sep 29 16:10 file.1
1971       0:user::rw-
1972       1:user:lp:rw-              #effective:r--
1973       2:group::r--               #effective:r--
1974       3:mask:r--
1975       4:other:r--
1977       $ chmod A1- file.1
1978       $ ls -v
1979 -rw-r--r--+  1 root     root           0 Sep 29 16:10 file.1
1980       0:user::rw-
1981       1:group::r--               #effective:r--
1982       2:mask:r--
1983       3:other:r--
1985 .in -2
1989 \fBExample 14 \fRRemoving All ACLs From a File
1992 The following command works with either NFSv4/ZFS or POSIX-draft ACLs.
1996 Consider the following ACL:
1999 .in +2
2001 $ ls -v file.3
2002 -rw-r--r--+  1 marks    staff          0 Oct  9 15:49 file.3
2003       0:user:lp:read_data/write_data:allow
2004       1:user:marks:read_acl:allow
2005       2:owner@:execute:deny
2006       3:owner@:read_data/write_data/append_data/write_xattr/
2007          write_attributes/write_acl/write_owner:allow
2008       4:group@:write_data/append_data/execute:deny
2009       5:group@:read_data:allow
2010       6:everyone@:write_data/append_data/write_xattr/execute/
2011          write_attributes/write_acl/write_owner:deny
2012       7:everyone@:read_data/read_xattr/read_attributes/read_acl/
2013          synchronize:allow
2015 .in -2
2020 The existing ACL is effectively removed and is replaced with an ACL that
2021 represents the permission bits of the file.
2024 .in +2
2026 $ chmod A- file.3
2027 $ ls -v file.3
2028 -rw-r--r--  1 marks    staff          0 Oct  9 15:49 file.3
2029      0:owner@:execute:deny
2030      1:owner@:read_data/write_data/append_data/write_xattr/
2031         write_attributes/write_acl/write_owner:allow
2032      2:group@:write_data/append_data/execute:deny
2033      3:group@:read_data:allow
2034      4:everyone@:write_data/append_data/write_xattr/execute/
2035         write_attributes/write_acl/write_owner:deny
2036      5:everyone@:read_data/read_xattr/read_attributes/read_acl/
2037        synchronize:allow
2039 .in -2
2043 \fBExample 15 \fRReplacing an Entire ACL Entry on a ZFS File
2046 Use the following \fBchmod\fR syntax if you want to replace an ACL in its
2047 entirety:
2050 .in +2
2052 $ chmod A=owner@:read_data/write_data:allow,group@:read_data/
2053                write_data:allow,user:lp:read_data:allow file.4
2054 $ ls -v file.4
2055 -rw-rw----+  1 marks    staff          0 Oct  9 16:12 file.4
2056        0:owner@:read_data/write_data:allow
2057        1:group@:read_data/write_data:allow
2058        2:user:lp:read_data:allow
2060 .in -2
2064 \fBExample 16 \fRReplacing an Entire POSIX-draft ACL on a UFS File
2067 This operation is a little more complicated.  The replacement ACL needs the
2068 necessary entries to represent the file owner, file group owner, other, mask
2069 and any additional entries you wish to set.
2072 .in +2
2074 $ chmod A=user::rw-,group::rw-,other::---,mask:r--,
2075               user:lp:r-- file.3
2076 $ ls -v file.3
2077 -rw-r-----+  1 root     root           0 Oct  9 16:14 file.3
2078         0:user::rw-
2079         1:user:lp:r--        #effective:r--
2080         2:group::rw-         #effective:r--
2081         3:mask:r--
2082         4:other:---
2084 .in -2
2088 \fBExample 17 \fRReplacing a Specific Entry on a ZFS File
2091 Consider the following ACL.
2094 .in +2
2096 $ ls -v file.5
2097 -rw-r--r--+  1 marks    staff          0 Oct  9 16:18 file.5
2098      0:user:marks:read_data:allow
2099      1:owner@:execute:deny
2100      2:owner@:read_data/write_data/append_data/write_xattr/
2101         write_attributes/write_acl/write_owner:allow
2102      3:group@:write_data/append_data/execute:deny
2103      4:group@:read_data:allow
2104      5:everyone@:write_data/append_data/write_xattr/execute/
2105         write_attributes/write_acl/write_owner:deny
2106      6:everyone@:read_data/read_xattr/read_attributes/read_acl/
2107         synchronize:allow
2109 .in -2
2114 Now, change the allow access to a deny for user marks:
2117 .in +2
2119 $ chmod A0=user:marks:read_data:deny file.5
2120 $ ls -v file.5
2121 -rw-r--r--+  1 marks   staff          0 Aug 23 09:11 file.5
2122 0:user:marks:read_data:deny
2123 1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
2124      /write_acl/write_owner:allow
2125 2:group@:write_data/append_data/execute:deny
2126 3:group@:read_data:allow
2127 4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
2128      /write_acl/write_owner:deny
2129 5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
2130      :allow
2132 .in -2
2136 \fBExample 18 \fRReplacing a Specific POSIX-draft ACL on a UFS File
2139 Consider the following ACL.
2142 .in +2
2144 $ ls -v file.4
2145 -rw-r--r--+  1 marks    staff          0 Oct  9 16:21 file.4
2146         0:user::rw-
2147         1:user:lp:rwx         #effective:r--
2148         2:group::r--          #effective:r--
2149         3:mask:r--
2150         4:other:r--
2152 .in -2
2157 Now, change the permission on \fBlp\fR from \fBrwx\fR to \fBr--\fR:
2160 .in +2
2162 $ chmod A1=user:lp:r-- file.4
2164 $ ls -v file
2165 -rw-r--r--+  1 marks    staff          0 Oct  9 16:21 file.4
2166         0:user::rw-
2167         1:user:lp:r--         #effective:r--
2168         2:group::r--          #effective:r--
2169         3:mask:r--
2170         4:other:r--
2172 .in -2
2176 \fBExample 19 \fRSetting ACL Inheritance Flags on a ZFS File
2179 You can only set inheritance flags on ZFS files. When setting ACLs on
2180 directories,  several inheritance flags can be optionally set.
2184 Suppose you have an ACL entry for user \fBlp\fR that you want to be  inherited
2185 to newly created files in a directory.  First, you need to create an
2186 inheritable ACL entry on the directory:
2189 .in +2
2191 $ chmod A+user:lp:read_data:file_inherit:allow test.dir
2192 $ ls -dv test.dir
2193 drwxr-xr-x+  2 marks   staff          2 Aug 23 09:08 test.dir/
2194 0:user:lp:read_data:file_inherit:allow
2195 1:owner@::deny
2196 2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
2197      /append_data/write_xattr/execute/write_attributes/write_acl
2198      /write_owner:allow
2199 3:group@:add_file/write_data/add_subdirectory/append_data:deny
2200 4:group@:list_directory/read_data/execute:allow
2201 5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
2202      /write_attributes/write_acl/write_owner:deny
2203 6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
2204      /read_acl/synchronize:allow
2206 .in -2
2211 The \fBlp\fR entry is inherited to newly created files in the directory
2212 \fBtest.dir\fR.
2215 .in +2
2217 $ touch test.dir/file.test
2218 $ ls -v test.dir/file.test
2219 -rw-r--r--+  1 marks    staff          0 Oct  9 16:29 test.dir/file.test
2220      0:user:lp::deny
2221      1:user:lp:read_data:allow
2222      2:owner@:execute:deny
2223      3:owner@:read_data/write_data/append_data/write_xattr/
2224          write_attributes/write_acl/write_owner:allow
2225      4:group@:write_data/append_data/execute:deny
2226      5:group@:read_data:allow
2227      6:everyone@:write_data/append_data/write_xattr/execute/
2228          write_attributes/write_acl/write_owner:deny
2229      7:everyone@:read_data/read_xattr/read_attributes/read_acl/
2230  synchronize:allow
2232 .in -2
2237 The user \fBlp\fR entry is inherited to the newly created file. Multiple
2238 combinations of the inheritance flags can be specified. For example, if you
2239 wanted the \fBlp\fR entry to also be inherited to  directories, then the
2240 following command can be used:
2243 .in +2
2245 $ chmod A+user:lp:read_data:file_inherit/\e
2246       dir_inherit:allow test.dir
2248 .in -2
2252 \fBExample 20 \fRReplacing System Attributes of a ZFS File
2255 The following examples replace system attributes of a ZFS file:
2258 .in +2
2260 $ chmod S=v{archive,hidden,readonly,system,appendonly,\e
2261      nonodump,immutable,noav_modified,noav_quarantined,\e
2262      nounlink,nooffline,nosparse} file1
2264 .in -2
2272 .in +2
2274 $ chmod S=c{AHRSaiu} file1
2276 .in -2
2284 .in +2
2286 $ chmod S=c{AHRSa-i--u--} file1
2288 .in -2
2296 .in +2
2298 $ chmod S=cAHRSaiu file1
2300 .in -2
2308 .in +2
2310 $ chmod -@ '..' S=cAHRSaiu file1
2312 .in -2
2317 Assuming appropriate privileges, this results in the following system
2318 attributes of \fBfile1\fR being set: \fBarchive\fR, \fBhidden\fR,
2319 \fBreadonly\fR, \fBsystem\fR, \fBappendonly\fR, \fBimmutable\fR, and
2320 \fBnounlink\fR. Assuming appropriate privileges, the following system
2321 attributes of \fBfile1\fR are cleared: \fBnodump\fR, \fBav_modified\fR,
2322 \fBav_quarantined\fR, \fBoffline\fR, and \fBsparse\fR.
2325 \fBExample 21 \fRClearing All System Attributes of a ZFS File
2328 The following examples clears all system attributes of a ZFS file:
2331 .in +2
2333 $ chmod S-a file1
2335 .in -2
2343 .in +2
2345 $ chmod -@ '..' S-a file1
2347 .in -2
2352 Assuming appropriate privileges, all boolean read-write system attributes are
2353 cleared on \fBfile1\fR.
2356 \fBExample 22 \fRSetting a System Attribute of a Named Attribute File of a ZFS
2357 File
2360 The following example sets a system attribute of a named attribute file of a
2361 ZFS file, but not of the file itself:
2364 .in +2
2366 $ chmod -@ myattr S+vhidden file1
2368 .in -2
2373 This results in the hidden system attribute being set for the named attribute
2374 file \fBmyattr\fR of \fBfile1\fR, but not the file itself.
2377 \fBExample 23 \fRSetting a System Attribute of All Named Attribute File of a
2378 ZFS File
2381 The following example sets a system attribute of all named attribute files of a
2382 ZFS file, but not of the file itself:
2385 .in +2
2387 $ chmod -@ '*' S+a file1
2389 .in -2
2393 \fBExample 24 \fRSetting a System Attribute of All Named Attribute Files of a
2394 ZFS File
2397 The following example sets a system attribute of all named attribute files of a
2398 ZFS file, as well as of the file itself:
2401 .in +2
2403 $ chmod -@ '..' -@ '*' S+vhidden file1
2405 .in -2
2410 This results in the hidden system attribute being set for all named attribute
2411 files of \fBfile1\fR, as well as the file itself.
2414 \fBExample 25 \fRRecursively Descending Through a Directory Hierarchy
2417 The following example recursively descends through a directory hierarchy, and
2418 sets all system attributes of all named attribute files, the ZFS file operands,
2419 as well as of the directory itself:
2422 .in +2
2424 $ chmod -R -@ '..' -@ '*' S+a directory1
2426 .in -2
2431 This results in the hidden system attribute being set for all named attribute
2432 files of all regular files and directories within the directory hierarchy of
2433 \fBdirectory1\fR, as well as of \fBdirectory1\fR itself.
2436 \fBExample 26 \fRSetting the \fBhidden\fR and \fBsystem\fR System Attributes of
2437 a ZFS File
2440 The following examples set the \fBhidden\fR and \fBsystem\fR system attributes
2441 of a ZFS file:
2444 .in +2
2446 $ chmod S+cHS file1
2448 .in -2
2456 .in +2
2458 $ chmod S+vhidden,+vsystem file1
2460 .in -2
2468 .in +2
2470 $ chmod S+v{hidden,system} file1
2472 .in -2
2480 .in +2
2482 $ chmod S+c{-H-S--------} file1
2484 .in -2
2492 .in +2
2494 $ chmod S-v{nohidden,nosystem} file1
2496 .in -2
2504 .in +2
2506 $ chmod S-v{hidden,system},+v{hidden,system} file1
2508 .in -2
2512 \fBExample 27 \fRClearing All System Attributes of a ZFS File
2515 The following example clears all system attributes of a ZFS file:
2518 .in +2
2520 $ chmod S-a file1
2522 .in -2
2530 .in +2
2532 $ chmod S=v{} file1
2534 .in -2
2539 In the following two examples, the last attribute operation specified takes
2540 precedence.
2544 In this example, the replacement attribute name list (\fB{}\fR) clears all
2545 system attributes for \fBfile1\fR:
2548 .in +2
2550 $ chmod S+cHS,=v{} file1
2552 .in -2
2557 In this example, the clear attributes operation (\fB-a\fR) clears all system
2558 attributes of \fBfile1\fR:
2561 .in +2
2563 $ chmod S+vhidden,+vsystem,-a file1
2565 .in -2
2569 \fBExample 28 \fRSetting the Values of All Boolean read-write System Attributes
2570 of a File
2573 The following example sets the values of all boolean read-write system
2574 attributes of a file to the same as the boolean read-write system attributes of
2575 another file:
2578 .in +2
2580 $ chmod S=v`ls -/v file1|sed -n '2s/.*{/{/p'` file2
2582 .in -2
2587 Assuming appropriate privileges and that \fBfile1\fR and \fBfile2\fR have the
2588 same supported system attributes, all system attributes of \fBfile1\fR that are
2589 set are also set on \fBfile2\fR. All system attributes of \fBfile1\fR that are
2590 cleared are also cleared on \fBfile2\fR.
2592 .SH ENVIRONMENT VARIABLES
2594 See \fBenviron\fR(5) for descriptions of the following environment variables
2595 that affect the execution of \fBchmod\fR: \fBLANG\fR, \fBLC_ALL\fR,
2596 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
2597 .SH EXIT STATUS
2599 The following exit values are returned:
2601 .ne 2
2603 \fB\fB0\fR\fR
2605 .RS 6n
2606 Successful completion.
2610 .ne 2
2612 \fB\fB>0\fR\fR
2614 .RS 6n
2615 An error occurred.
2618 .SH ATTRIBUTES
2620 See \fBattributes\fR(5) for descriptions of the following attributes:
2625 box;
2626 c | c
2627 l | l .
2628 ATTRIBUTE TYPE  ATTRIBUTE VALUE
2630 CSI     Enabled
2632 Interface Stability     Committed
2635 .SH SEE ALSO
2637 \fBgetfacl\fR(1), \fBls\fR(1), \fBsetfacl\fR(1), \fBchmod\fR(2),
2638 \fBfgetattr\fR(3C), \fBacl\fR(5), \fBattributes\fR(5), \fBenviron\fR(5),
2639 \fBfsattr\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
2640 .SH NOTES
2642 Absolute changes do not work for the set-group-\fBID\fR bit of a directory. You
2643 must use \fBg+s\fR or \fBg-s\fR.
2646 \fBchmod\fR permits you to produce useless modes so long as they are not
2647 illegal (for instance, making a text file executable). \fBchmod\fR does not
2648 check the file type to see if mandatory locking is meaningful.
2651 If the filesystem is mounted with the \fInosuid\fR option, \fIsetuid\fR
2652 execution is not allowed.
2655 If you use \fBchmod\fR to change the file group owner permissions on a file
2656 with \fBACL\fR entries, both the file group owner permissions and the \fBACL\fR
2657 mask are changed to the new permissions. Be aware that the new \fBACL\fR mask
2658 permissions can change the effective permissions for additional users and
2659 groups who have \fBACL\fR entries on the file. Use the \fBgetfacl\fR(1) or
2660 \fBls\fR(1) command to make sure the appropriate permissions are set for all
2661 \fBACL\fR entries.