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"
16 chmod \- change the permissions mode of a file
20 \fBchmod\fR [\fB-fR\fR] \fIabsolute-mode\fR \fIfile\fR...
25 \fBchmod\fR [\fB-fR\fR] \fIsymbolic-mode-list\fR \fIfile\fR...
30 \fBchmod\fR [\fB-fR\fR] \fIacl_operation\fR \fIfile\fR...
35 \fBchmod\fR [\fB-fR\fR] [\fB-@\fR \fInamed_attribute\fR]...\fIattribute_specification_list\fR \fIfile\fR...
40 The \fBchmod\fR utility changes or assigns the mode of a file.
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.
48 An absolute mode command line has the following format:
51 \fBchmod\fR [\fIoptions\fR] \fIabsolute-mode\fR \fIfile\fR . . .
54 where \fIabsolute-mode\fR is specified using octal numbers \fInnnn\fR defined
62 a number from \fB0\fR to \fB7\fR. An absolute mode is constructed from the OR
63 of any of the following modes:
70 Set user \fBID\fR on execution.
76 \fB\fB20\fR\fI\|#\|\fR\fB0\fR\fR
79 Set group \fBID\fR on execution if \fI#\fR is \fB7\fR, \fB5\fR, \fB3\fR, or
82 Enable mandatory locking if \fI#\fR is \fB6\fR, \fB4\fR, \fB2\fR, or \fB0\fR.
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.
96 Turn on sticky bit. See \fBchmod\fR(2).
114 Allow write by owner.
123 Allow execute (search in directory) by owner.
132 Allow read, write, and execute (search) by owner.
150 Allow write by group.
159 Allow execute (search in directory) by group.
168 Allow read, write, and execute (search) by group.
177 Allow read by others.
186 Allow write by others.
195 Allow execute (search in directory) by others.
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
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
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:
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.
288 either \fB+\fR, \fB\(mi\fR, or \fB=\fR, signifying how permissions are to be
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
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
322 If \fBwho\fR is present, clear the file mode bits represented by
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
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.
355 \fB\fIpermission\fR\fR
358 any compatible combination of the following letters:
419 execute permission if the file is a directory or if there is execute permission
420 for one of the other user classes
426 \fB\fBu\fR,\fBg\fR,\fBo\fR\fR
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:
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
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
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:
469 chmod g+x,+l \fIfile\fR
470 chmod g+s,+l \fIfile\fR
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
485 An ACL Operation command line has the following format:
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 ...
498 Where \fIacl_specification\fR is a comma-separated list (with no intervening
499 white space) of an ACL specification of the form:
503 \fB\fBA[\fIindex\fR]+\fIacl_specification\fR\fR\fR
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.
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.
525 \fB\fBA\fIindex\fR\fR-\fR
528 Removes ACE specified by \fIindex\fR number.
534 \fB\fBA-\fIacl_specification\fR\fR\fR
541 Removes ACEs specified by \fIacl_specification\fR, if they exist in current
548 \fB\fBA=\fIacl_specification\fR\fR\fR
551 Replaces a files entire ACL with \fIacl_specification\fR.
557 \fB\fBA[\fIindex\fR]=\fIacl_specification\fR\fR\fR
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.
579 File owner permissions.
585 \fBuser:\fIusername\fR:perms\fR
589 Permissions for a specific user.
599 File group owner permissions.
605 \fBgroup:\fIgroupname:\fRperms\fR
609 Permissions for a specific group.
619 Permissions for user other than the file owner or members of file group owner.
629 The ACL mask. The mask entry specifies the maximum permissions allowed for user
630 (other than that the owner) and for groups.
636 \fBdefault:user::perms\fR
640 Default file owner permissions.
646 \fBdefault:user:\fIusername\fR:perms\fR
650 Default permissions for a specific user.
656 \fBdefault:group::perms\fR
660 Default file group owner permissions.
666 \fBdefault:group:\fIgroupname\fR:perms\fR
670 Default permissions for a specific group.
676 \fBdefault:other:perms\fR
680 Default permissions for user other than the file owner or members of the file
687 \fBdefault:mask:perms\fR
696 The above specification allows for ACLs to be specified such as:
700 user:tom:rw-,mask:rwx,group:staff:r-x
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.
718 \fBowner@:<perms>[:inheritance flags]:<allow|deny>\fR
722 Permissions for file owner.
728 \fBgroup@:<perms>[:inheritance flags]:<allow|deny>\fR
732 Permissions for file group owner.
738 \fBeveryone@:<perms>[:inheritance flags]:<allow|deny>\fR
742 Permissions for everyone, including file owner and group owner.
748 \fBuser:<username>:<perms>[:inheritance flags]:<allow|deny>\fR
752 Permissions for a specific user.
758 \fBusersid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
762 Permissions for a specific user, but user is specified by SID.
768 \fBgroup:<groupname>:<perms>[:inheritance flags]:<allow|deny>\fR
772 Permissions for a specific group.
778 \fBgroupsid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
782 Permissions for a specific group, but group is specified by SID.
788 \fBsid:<sid string>:<perms>[:inheritance flags]:<allow|deny>\fR
792 Permissions for a specific SID, but it doesn't matter if it is a user or a
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:
810 \fBread_data (\fBr\fR)\fR
813 Permission to read the data of a file.
819 \fBlist_directory (\fBr\fR)\fR
822 Permission to list the contents of a directory.
828 \fBwrite_data (\fBw\fR)\fR
831 Permission to modify a file's data. anywhere in the file's offset range.
837 \fBadd_file (\fBw\fR)\fR
840 Permission to add a new file to a directory.
846 \fBappend_data (\fBp\fR)\fR
849 The ability to modify a file's data, but only starting at EOF.
851 Currently, this permission is not supported.
857 \fBadd_subdirectory (\fBp\fR)\fR
860 Permission to create a subdirectory to a directory.
866 \fBread_xattr (\fBR\fR)\fR
869 Ability to read the extended attributes of a file.
875 \fBwrite_xattr (\fBW\fR)\fR
878 Ability to create extended attributes or write to the extended attribute
885 \fBexecute (\fBx\fR)\fR
888 Permission to execute a file.
894 \fBread_attributes (\fBa\fR)\fR
897 The ability to read basic attributes (non-ACLs) of a file.
903 \fBwrite_attributes (\fBA\fR)\fR
906 Permission to change the times associated with a file or directory to an
913 \fBdelete (\fBd\fR)\fR
916 Permission to delete a file.
922 \fBdelete_child (\fBD\fR)\fR
925 Permission to delete a file within a directory.
931 \fBread_acl (\fBc\fR)\fR
934 Permission to read the ACL of a file.
940 \fBwrite_acl (\fBC\fR)\fR
943 Permission to write the ACL of a file.
949 \fBwrite_owner (\fBo\fR)\fR
952 Permission to change the owner of a file.
958 \fBsynchronize (\fBs\fR)\fR
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
982 Permissions can be specified with these letters in the following way:
993 The hyphens can be removed to compact the string as follows:
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.
1009 \fB\fBfull_set\fR\fR
1018 \fB\fBmodify_set\fR\fR
1021 All permissions except \fBwrite_acl\fR and \fBwrite_owner\fR.
1027 \fB\fBread_set\fR\fR
1030 \fBread_data, read_acl, read_attributes,\fR and \fBread_xattr\fR.
1036 \fB\fBwrite_set\fR\fR
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.
1050 \fBfile_inherit (\fBf\fR)\fR
1053 Inherit to all newly created files.
1059 \fBdir_inherit (\fBd\fR)\fR
1062 Inherit to all newly created directories.
1068 \fBinherit_only (\fBi\fR)\fR
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.
1079 \fBno_propagate (\fBn\fR)\fR
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.
1089 The inheritance flags listed can also be specified in the compact format or as
1090 positional arguments similar to the \fBls\fR \fB-V\fR format. A hyphen
1091 character indicates that the inheritance flag at that position is not specified
1092 in the positional ACL format.
1095 The inheritance flags can be specified with these letters in any of the
1096 following equivalent ways.
1100 file_inherit/dir_inherit/no_propagate
1123 With this inheritance model, an ACL entry can be specified such as:
1127 user:tom:read_data/write_data/read_attributes:file_inherit:allow
1128 user:fred:read_data:file_inherit/dir_inherit:deny
1129 user:bob:read_data:allow
1134 .SS "Attribute Operation"
1136 An attribute operation command line has the following format:
1140 chmod [\fIoptions\fR] \fIattribute_specification_list\fR \fIfile\fR ...
1147 where \fIattribute_specification_list\fR is the character \fBS\fR followed by a
1148 comma-separated list of one or more \fIattribute_specifications\fR. Each
1149 \fIattribute_specification\fR is of the form:
1153 [\fIoperator\fR]\fIattribute_specifier\fR
1160 An \fIoperator\fR is one of the following:
1167 Each attribute specified by the associated \fIattribute_specifier\fR is
1168 adjusted to match the value specified by the \fIattribute_specifier\fR.
1177 Each attribute specified by the associated \fIattribute_specifier\fR is
1178 adjusted to match the inverse of the value specified by the
1179 \fIattribute_specifier\fR.
1188 Each attribute specified by the associated \fIattribute_specifier\fR is
1189 adjusted to match the value specified by the \fIattribute_specifier\fR. Any
1190 boolean read-write extended system attributes associated with the current file
1191 that are not specified by \fIattribute_specifier\fR is cleared.
1196 If an \fIoperator\fR is not specified in an \fIattribute_specification\fR,
1197 \fBchmod\fR behaves as if \fB+\fR had been specified.
1200 An \fIattribute_specifier\fR takes one of the following forms:
1208 Set all boolean read-write extended system attributes associated with the
1215 \fB\fBc[\fIcompact_attribute_list\fR]\fR\fR
1219 \fB\fBc'{'\fIcompact_attribute_list\fR'}'\fR\fR
1223 Set each boolean read-write extended system attribute identified by
1224 \fIcompact_attribute_list\fR.
1230 \fB\fBv[\fIverbose_attribute_setting\fR]\fR\fR
1234 \fB\fBv['{'\fIverbose_attribute_setting_list\fR'}']\fR\fR
1238 Set each boolean read-write extended system attribute identified by
1239 \fIverbose_attribute_setting\fR.
1244 A \fIcompact_attribute_list\fR is a list of zero or more adjacent attribute
1245 abbreviation characters from list of \fBAttribute Names and Abbreviation
1246 Characters\fR later in this section. An arbitrary number of hyphen (\fB-\fR)
1247 characters can be included in a \fIcompact_attribute_list\fR. These are
1251 A \fIverbose_attribute_setting\fR is an attribute name from the list of
1252 \fBAttribute Names and Abbreviation Characters\fR later in this section,
1253 optionally, immediately preceded by \fBno\fR. If the attribute name is used
1254 without \fBno\fR, the attribute is set; otherwise the attribute is cleared.
1257 A \fIverbose_attribute_setting_list\fR is zero or more comma-separated
1258 \fIverbose_attribute_setting\fRs.
1261 Multiple operations specified for a file are accumulated and are all set for a
1262 file operand as a single attribute setting operation. If an attribute is
1263 specified more than once in an \fIattribute_specification_list\fR, the last
1264 specified operation is applied.
1267 The following is a list of \fBAttribute Names and Abbreviation Characters\fR:
1271 \fB\fBAttribute Name\fR\fR
1274 \fBAbbreviation Character\fR
1298 \fB\fBreadonly\fR\fR
1316 \fB\fBnounlink\fR\fR
1325 \fB\fBimmutable\fR\fR
1334 \fB\fBappendonly\fR\fR
1352 \fB\fBav_quarantined\fR\fR
1361 \fB\fBav_modified\fR\fR
1387 The following options are supported:
1394 Force. \fBchmod\fR does not complain if it fails to change the mode of a file.
1403 Recursively descend through directory arguments, setting the mode for each
1404 file. When symbolic links are encountered, the mode of the target file is
1405 changed, but no recursion takes place.
1411 \fB\fB-@\fR \fInamed_attribute\fR\fR
1414 Perform the attribute operation on the named extended attribute file of each
1415 file operand instead of the file operand itself. If multiple \fB-@\fR
1416 operations are supplied, the attribute specification mode is applied to each of
1417 the named attribute files.
1419 A named attribute of \fB*\fR carries meaning to \fBchmod\fR, and is considered
1420 to mean all extended attribute files associated with a file operand. This does
1421 not refer to the special files \fB\&.\fR and \fB\&..\fR.
1423 A named attribute of \fB\&..\fR carries special meaning to \fBchmod\fR, and is
1424 considered to mean the file operand itself. This allows \fBchmod\fR, in a
1425 single call, to apply the attribute specification mode to the specified named
1426 attribute file of the file operand and the file operand itself.
1431 The following operands are supported:
1435 \fB\fIabsolute-mode\fR\fR
1439 \fB\fIsymbolic-mode-list\fR\fR
1443 Represents the change to be made to the file mode bits of each file named by
1444 one of the \fIfile\fR operands. See \fBAbsolute Mode\fR and \fBSymbolic Mode\fR
1445 in the \fBDESCRIPTION\fR section of this manual page for more information.
1451 \fB\fIacl_operation\fR\fR
1455 Represents the modification to be performed on the file's ACL. See \fBACL
1456 Operation\fR in the \fBDESCRIPTION\fR section for more information.
1458 \fIacl_operation\fR is one of the following:
1462 \fBA[\fR\fInumber\fR\fB] -\fR
1463 \fBA-\fR\fIacl_specification\fR
1464 \fBA[\fR\fIindex\fR\fB]{+|=}\fR\fBacl_specification\fR
1474 \fB\fIattribute_specification_list\fR\fR
1478 Represents the modification to performed on the file's attributes. See
1479 Attribute Operation in the \fBDESCRIPTION\fR section of this manual page for
1490 A path name of a file whose file mode bits are to be modified.
1495 See \fBlargefile\fR(5) for the description of the behavior of \fBchmod\fR when
1496 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
1499 \fBExample 1 \fRDenying \fBexecute\fR Permission
1502 The following example denies execute permission to everyone:
1507 % chmod a-x \fIfile\fR
1513 \fBExample 2 \fRAllowing \fBread-only\fR Permission
1516 The following example allows only read permission to everyone:
1521 % chmod 444 \fIfile\fR
1527 \fBExample 3 \fRMaking a File \fBreadable\fR and \fBwritable\fR
1530 The following example makes a file readable and writable by the group and
1536 % chmod go+rw \fIfile\fR
1537 % chmod 066 \fIfile\fR
1543 \fBExample 4 \fRLocking a File From Access
1546 The following example locks a file from access:
1551 $ chmod +l \fIfile\fR
1557 \fBExample 5 \fRGranting \fBread\fR, \fBwrite\fR, \fBexecute\fR, and \fBset
1558 group-ID\fR Permission on a File
1561 The following example grants everyone read, write, and execute permissions on
1562 the file, and turns on the set group-ID:
1567 $ chmod a=rwx,g+s \fIfile\fR
1568 $ chmod 2777 \fIfile\fR
1574 \fBExample 6 \fRPrepending a New ACL Entry on a ZFS File
1577 The following example prepends a new ACL entry on a ZFS file.
1581 First, display the current ACL:
1587 -rw-r--r-- 1 marks staff 0 Oct 9 15:49 file.3
1588 0:owner@:execute:deny
1589 1:owner@:read_data/write_data/append_data/write_xattr/
1590 write_attributes/write_acl/write_owner:allow
1591 2:group@:write_data/append_data/execute:deny
1592 3:group@:read_data:allow
1593 4:everyone@:write_data/append_data/write_xattr/execute/
1594 write_attributes/write_acl/write_owner:deny
1595 5:everyone@:read_data/read_xattr/read_attributes/read_acl/
1603 Issue the following command:
1608 $ chmod A+user:lp:read_data:deny file.3
1615 Display the new ACL:
1621 -rw-r--r--+ 1 marks staff 0 Oct 9 15:49 file.3
1622 0:user:lp:read_data:deny
1623 1:owner@:execute:deny
1624 2:owner@:read_data/write_data/append_data/write_xattr/
1625 write_attributes/write_acl/write_owner:allow
1626 3:group@:write_data/append_data/execute:deny
1627 4:group@:read_data:allow
1628 5:everyone@:write_data/append_data/write_xattr/execute/
1629 write_attributes/write_acl/write_owner:deny
1630 6:everyone@:read_data/read_xattr/read_attributes/read_acl/
1637 \fBExample 7 \fRPrepending a New POSIX-draft ACL Entry on a UFS File
1640 The following example prepends a new POSIX-draft ACL entry on a UFS file.
1644 First, display the current ACL:
1650 -rw-r--r-- 1 marks staff 0 Oct 9 15:52 file.2
1652 1:group::r-- #effective:r--
1661 Issue the following command:
1666 $ chmod A+user:lp:-wx file.2
1673 Display the new ACL:
1679 -rw-r--r--+ 1 marks staff 0 Oct 9 15:52 file.2
1681 1:user:lp:-wx #effective:---
1682 2:group::r-- #effective:r--
1690 \fBExample 8 \fRInserting an ACL Entry in a Specific Position on a ZFS file
1693 The following example inserts an ACL entry in a specific position on a ZFS file
1694 system. It also illustrates the compact ACL format.
1698 First, display the ACL to pick a location to insert a new ACE.
1704 -rw-r--r--+ 1 root root 0 Oct 6 12:16 file.1
1705 user:lp:rw------------:------:allow
1706 owner@:--x-----------:------:deny
1707 owner@:rw-p---A-W-Co-:------:allow
1708 group@:-wxp----------:------:deny
1709 group@:r-------------:------:allow
1710 everyone@:-wxp---A-W-Co-:------:deny
1711 everyone@:r-----a-R-c--s:------:allow
1718 Next, insert a new entry in location 3. This causes the entries that are
1719 currently in position 3 - 6 to be pushed down.
1723 Issue the following command:
1728 $ chmod A3+user:marks:r:deny file.1
1735 Display the new ACL:
1741 -rw-r--r--+ 1 root staff 0 Feb 3 14:13 file.1
1742 user:lp:rw------------:------:allow
1743 owner@:--x-----------:------:deny
1744 owner@:rw-p---A-W-Co-:------:allow
1745 user:marks:r-------------:------:deny
1746 group@:-wxp----------:------:deny
1747 group@:r-------------:------:allow
1748 everyone@:-wxp---A-W-Co-:------:deny
1749 everyone@:r-----a-R-c--s:------:allow
1755 \fBExample 9 \fRInserting a POSIX-draft ACL in a Specific Position on a UFS
1759 The file system reorders ACLs when they are stored in the file system. The
1760 following example illustrates this behavior.
1766 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1768 1:user:lp:rw- #effective:r--
1769 2:group::r-- #effective:r--
1778 Now, insert an entry at index position 3. The command works, but the file
1779 system reorders the ACL.
1784 $ chmod A3+user:marks:rw- file.1
1786 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1788 1:user:lp:rw- #effective:r--
1789 2:user:marks:rw- #effective:r--
1790 3:group::r-- #effective:r--
1799 Rather than inserting the ACL entry in position 3 as requested, it actually
1800 ends up in position 2.
1803 \fBExample 10 \fRRemoving an ACL Entry on a ZFS File
1806 The following example removes the \fBlp\fR entry from an ACL:
1812 -rw-r--r--+ 1 marks staff 0 Oct 9 15:49 file.3
1813 0:user:lp:read_data:deny
1814 1:owner@:execute:deny
1815 2:owner@:read_data/write_data/append_data/write_xattr/
1816 write_attributes/write_acl/write_owner:allow
1817 3:group@:write_data/append_data/execute:deny
1818 4:group@:read_data:allow
1819 5:everyone@:write_data/append_data/write_xattr/execute/
1820 write_attributes/write_acl/write_owner:deny
1821 6:everyone@:read_data/read_xattr/read_attributes/read_acl/
1830 $ chmod A-user:lp:read_data:deny file.3
1832 -rw-r--r-- 1 marks staff 0 Oct 9 15:49 file.3
1833 0:owner@:execute:deny
1834 1:owner@:read_data/write_data/append_data/write_xattr/
1835 write_attributes/write_acl/write_owner:allow
1836 2:group@:write_data/append_data/execute:deny
1837 3:group@:read_data:allow
1838 4:everyone@:write_data/append_data/write_xattr/execute/
1839 write_attributes/write_acl/write_owner:deny
1840 5:everyone@:read_data/read_xattr/read_attributes/read_acl/
1847 \fBExample 11 \fRRemoving a POSIX-draft ACL on a UFS File
1850 The following example removes the \fBlp\fR entry from an ACL:
1856 -rw-r--r--+ 1 marks staff 0 Oct 9 15:52 file.2
1858 1:user:lp:-wx #effective:---
1859 2:group::r-- #effective:r--
1869 $ chmod A-user:lp:-wx file.2
1871 -rw-r--r-- 1 marks staff 0 Oct 9 15:52 file.2
1873 1:group::r-- #effective:r--
1881 \fBExample 12 \fRRemoving a Specific ACL Entry by Index Number on a ZFS File
1884 Consider the following ACL:
1890 0:group:staff:read_data/write_data/execute/read_acl:allow
1891 1:user:bin:read_data:deny
1892 2:user:bin:read_data:allow
1893 3:owner@:write_data/append_data:deny
1894 4:owner@:read_data/write_xattr/execute/write_attributes/write_acl
1896 5:group@:write_data/append_data:deny
1897 6:group@:read_data/execute:allow
1898 7:everyone@:write_data/append_data/write_xattr/write_attributes
1899 /write_acl/write_owner:deny
1900 8:everyone@:read_data/read_xattr/execute/read_attributes/read_acl
1908 Remove the second user entry for bin.
1915 0:group:staff:read_data/write_data/execute/read_acl:allow
1916 1:user:bin:read_data:deny
1917 2:owner@:write_data/append_data:deny
1918 3:owner@:read_data/write_xattr/execute/write_attributes/write_acl
1920 4:group@:write_data/append_data:deny
1921 5:group@:read_data/execute:allow
1922 6:everyone@:write_data/append_data/write_xattr/write_attributes
1923 /write_acl/write_owner:deny
1924 7:everyone@:read_data/read_xattr/execute/read_attributes/read_acl
1931 \fBExample 13 \fRRemoving a Specific POSIX-draft ACL Entry on a UFS File
1934 The following example removes the lp entry by index number from the following
1941 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1943 1:user:lp:rw- #effective:r--
1944 2:group::r-- #effective:r--
1950 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1952 1:group::r-- #effective:r--
1960 \fBExample 14 \fRRemoving All ACLs From a File
1963 The following command works with either NFSv4/ZFS or POSIX-draft ACLs.
1967 Consider the following ACL:
1973 -rw-r--r--+ 1 marks staff 0 Oct 9 15:49 file.3
1974 0:user:lp:read_data/write_data:allow
1975 1:user:marks:read_acl:allow
1976 2:owner@:execute:deny
1977 3:owner@:read_data/write_data/append_data/write_xattr/
1978 write_attributes/write_acl/write_owner:allow
1979 4:group@:write_data/append_data/execute:deny
1980 5:group@:read_data:allow
1981 6:everyone@:write_data/append_data/write_xattr/execute/
1982 write_attributes/write_acl/write_owner:deny
1983 7:everyone@:read_data/read_xattr/read_attributes/read_acl/
1991 The existing ACL is effectively removed and is replaced with an ACL that
1992 represents the permission bits of the file.
1999 -rw-r--r-- 1 marks staff 0 Oct 9 15:49 file.3
2000 0:owner@:execute:deny
2001 1:owner@:read_data/write_data/append_data/write_xattr/
2002 write_attributes/write_acl/write_owner:allow
2003 2:group@:write_data/append_data/execute:deny
2004 3:group@:read_data:allow
2005 4:everyone@:write_data/append_data/write_xattr/execute/
2006 write_attributes/write_acl/write_owner:deny
2007 5:everyone@:read_data/read_xattr/read_attributes/read_acl/
2014 \fBExample 15 \fRReplacing an Entire ACL Entry on a ZFS File
2017 Use the following \fBchmod\fR syntax if you want to replace an ACL in its
2023 $ chmod A=owner@:read_data/write_data:allow,group@:read_data/
2024 write_data:allow,user:lp:read_data:allow file.4
2026 -rw-rw----+ 1 marks staff 0 Oct 9 16:12 file.4
2027 0:owner@:read_data/write_data:allow
2028 1:group@:read_data/write_data:allow
2029 2:user:lp:read_data:allow
2035 \fBExample 16 \fRReplacing an Entire POSIX-draft ACL on a UFS File
2038 This operation is a little more complicated. The replacement ACL needs the
2039 necessary entries to represent the file owner, file group owner, other, mask
2040 and any additional entries you wish to set.
2045 $ chmod A=user::rw-,group::rw-,other::---,mask:r--,
2048 -rw-r-----+ 1 root root 0 Oct 9 16:14 file.3
2050 1:user:lp:r-- #effective:r--
2051 2:group::rw- #effective:r--
2059 \fBExample 17 \fRReplacing a Specific Entry on a ZFS File
2062 Consider the following ACL.
2068 -rw-r--r--+ 1 marks staff 0 Oct 9 16:18 file.5
2069 0:user:marks:read_data:allow
2070 1:owner@:execute:deny
2071 2:owner@:read_data/write_data/append_data/write_xattr/
2072 write_attributes/write_acl/write_owner:allow
2073 3:group@:write_data/append_data/execute:deny
2074 4:group@:read_data:allow
2075 5:everyone@:write_data/append_data/write_xattr/execute/
2076 write_attributes/write_acl/write_owner:deny
2077 6:everyone@:read_data/read_xattr/read_attributes/read_acl/
2085 Now, change the allow access to a deny for user marks:
2090 $ chmod A0=user:marks:read_data:deny file.5
2092 -rw-r--r--+ 1 marks staff 0 Aug 23 09:11 file.5
2093 0:user:marks:read_data:deny
2094 1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
2095 /write_acl/write_owner:allow
2096 2:group@:write_data/append_data/execute:deny
2097 3:group@:read_data:allow
2098 4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
2099 /write_acl/write_owner:deny
2100 5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
2107 \fBExample 18 \fRReplacing a Specific POSIX-draft ACL on a UFS File
2110 Consider the following ACL.
2116 -rw-r--r--+ 1 marks staff 0 Oct 9 16:21 file.4
2118 1:user:lp:rwx #effective:r--
2119 2:group::r-- #effective:r--
2128 Now, change the permission on \fBlp\fR from \fBrwx\fR to \fBr--\fR:
2133 $ chmod A1=user:lp:r-- file.4
2136 -rw-r--r--+ 1 marks staff 0 Oct 9 16:21 file.4
2138 1:user:lp:r-- #effective:r--
2139 2:group::r-- #effective:r--
2147 \fBExample 19 \fRSetting ACL Inheritance Flags on a ZFS File
2150 You can only set inheritance flags on ZFS files. When setting ACLs on
2151 directories, several inheritance flags can be optionally set.
2155 Suppose you have an ACL entry for user \fBlp\fR that you want to be inherited
2156 to newly created files in a directory. First, you need to create an
2157 inheritable ACL entry on the directory:
2162 $ chmod A+user:lp:read_data:file_inherit:allow test.dir
2164 drwxr-xr-x+ 2 marks staff 2 Aug 23 09:08 test.dir/
2165 0:user:lp:read_data:file_inherit:allow
2167 2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
2168 /append_data/write_xattr/execute/write_attributes/write_acl
2170 3:group@:add_file/write_data/add_subdirectory/append_data:deny
2171 4:group@:list_directory/read_data/execute:allow
2172 5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
2173 /write_attributes/write_acl/write_owner:deny
2174 6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
2175 /read_acl/synchronize:allow
2182 The \fBlp\fR entry is inherited to newly created files in the directory
2188 $ touch test.dir/file.test
2189 $ ls -v test.dir/file.test
2190 -rw-r--r--+ 1 marks staff 0 Oct 9 16:29 test.dir/file.test
2192 1:user:lp:read_data:allow
2193 2:owner@:execute:deny
2194 3:owner@:read_data/write_data/append_data/write_xattr/
2195 write_attributes/write_acl/write_owner:allow
2196 4:group@:write_data/append_data/execute:deny
2197 5:group@:read_data:allow
2198 6:everyone@:write_data/append_data/write_xattr/execute/
2199 write_attributes/write_acl/write_owner:deny
2200 7:everyone@:read_data/read_xattr/read_attributes/read_acl/
2208 The user \fBlp\fR entry is inherited to the newly created file. Multiple
2209 combinations of the inheritance flags can be specified. For example, if you
2210 wanted the \fBlp\fR entry to also be inherited to directories, then the
2211 following command can be used:
2216 $ chmod A+user:lp:read_data:file_inherit/\e
2217 dir_inherit:allow test.dir
2223 \fBExample 20 \fRReplacing System Attributes of a ZFS File
2226 The following examples replace system attributes of a ZFS file:
2231 $ chmod S=v{archive,hidden,readonly,system,appendonly,\e
2232 nonodump,immutable,noav_modified,noav_quarantined,\e
2233 nounlink,nooffline,nosparse} file1
2245 $ chmod S=c{AHRSaiu} file1
2257 $ chmod S=c{AHRSa-i--u--} file1
2269 $ chmod S=cAHRSaiu file1
2281 $ chmod -@ '..' S=cAHRSaiu file1
2288 Assuming appropriate privileges, this results in the following system
2289 attributes of \fBfile1\fR being set: \fBarchive\fR, \fBhidden\fR,
2290 \fBreadonly\fR, \fBsystem\fR, \fBappendonly\fR, \fBimmutable\fR, and
2291 \fBnounlink\fR. Assuming appropriate privileges, the following system
2292 attributes of \fBfile1\fR are cleared: \fBnodump\fR, \fBav_modified\fR,
2293 \fBav_quarantined\fR, \fBoffline\fR, and \fBsparse\fR.
2296 \fBExample 21 \fRClearing All System Attributes of a ZFS File
2299 The following examples clears all system attributes of a ZFS file:
2316 $ chmod -@ '..' S-a file1
2323 Assuming appropriate privileges, all boolean read-write system attributes are
2324 cleared on \fBfile1\fR.
2327 \fBExample 22 \fRSetting a System Attribute of a Named Attribute File of a ZFS
2331 The following example sets a system attribute of a named attribute file of a
2332 ZFS file, but not of the file itself:
2337 $ chmod -@ myattr S+vhidden file1
2344 This results in the hidden system attribute being set for the named attribute
2345 file \fBmyattr\fR of \fBfile1\fR, but not the file itself.
2348 \fBExample 23 \fRSetting a System Attribute of All Named Attribute File of a
2352 The following example sets a system attribute of all named attribute files of a
2353 ZFS file, but not of the file itself:
2358 $ chmod -@ '*' S+a file1
2364 \fBExample 24 \fRSetting a System Attribute of All Named Attribute Files of a
2368 The following example sets a system attribute of all named attribute files of a
2369 ZFS file, as well as of the file itself:
2374 $ chmod -@ '..' -@ '*' S+vhidden file1
2381 This results in the hidden system attribute being set for all named attribute
2382 files of \fBfile1\fR, as well as the file itself.
2385 \fBExample 25 \fRRecursively Descending Through a Directory Hierarchy
2388 The following example recursively descends through a directory hierarchy, and
2389 sets all system attributes of all named attribute files, the ZFS file operands,
2390 as well as of the directory itself:
2395 $ chmod -R -@ '..' -@ '*' S+a directory1
2402 This results in the hidden system attribute being set for all named attribute
2403 files of all regular files and directories within the directory hierarchy of
2404 \fBdirectory1\fR, as well as of \fBdirectory1\fR itself.
2407 \fBExample 26 \fRSetting the \fBhidden\fR and \fBsystem\fR System Attributes of
2411 The following examples set the \fBhidden\fR and \fBsystem\fR system attributes
2429 $ chmod S+vhidden,+vsystem file1
2441 $ chmod S+v{hidden,system} file1
2453 $ chmod S+c{-H-S--------} file1
2465 $ chmod S-v{nohidden,nosystem} file1
2477 $ chmod S-v{hidden,system},+v{hidden,system} file1
2483 \fBExample 27 \fRClearing All System Attributes of a ZFS File
2486 The following example clears all system attributes of a ZFS file:
2510 In the following two examples, the last attribute operation specified takes
2515 In this example, the replacement attribute name list (\fB{}\fR) clears all
2516 system attributes for \fBfile1\fR:
2521 $ chmod S+cHS,=v{} file1
2528 In this example, the clear attributes operation (\fB-a\fR) clears all system
2529 attributes of \fBfile1\fR:
2534 $ chmod S+vhidden,+vsystem,-a file1
2540 \fBExample 28 \fRSetting the Values of All Boolean read-write System Attributes
2544 The following example sets the values of all boolean read-write system
2545 attributes of a file to the same as the boolean read-write system attributes of
2551 $ chmod S=v`ls -/v file1|sed -n '2s/.*{/{/p'` file2
2558 Assuming appropriate privileges and that \fBfile1\fR and \fBfile2\fR have the
2559 same supported system attributes, all system attributes of \fBfile1\fR that are
2560 set are also set on \fBfile2\fR. All system attributes of \fBfile1\fR that are
2561 cleared are also cleared on \fBfile2\fR.
2563 .SH ENVIRONMENT VARIABLES
2565 See \fBenviron\fR(5) for descriptions of the following environment variables
2566 that affect the execution of \fBchmod\fR: \fBLANG\fR, \fBLC_ALL\fR,
2567 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
2570 The following exit values are returned:
2577 Successful completion.
2591 See \fBattributes\fR(5) for descriptions of the following attributes:
2599 ATTRIBUTE TYPE ATTRIBUTE VALUE
2603 Interface Stability Committed
2608 \fBgetfacl\fR(1), \fBls\fR(1), \fBsetfacl\fR(1), \fBchmod\fR(2),
2609 \fBfgetattr\fR(3C), \fBacl\fR(5), \fBattributes\fR(5), \fBenviron\fR(5),
2610 \fBfsattr\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
2613 Absolute changes do not work for the set-group-\fBID\fR bit of a directory. You
2614 must use \fBg+s\fR or \fBg-s\fR.
2617 \fBchmod\fR permits you to produce useless modes so long as they are not
2618 illegal (for instance, making a text file executable). \fBchmod\fR does not
2619 check the file type to see if mandatory locking is meaningful.
2622 If the filesystem is mounted with the \fInosuid\fR option, \fIsetuid\fR
2623 execution is not allowed.
2626 If you use \fBchmod\fR to change the file group owner permissions on a file
2627 with \fBACL\fR entries, both the file group owner permissions and the \fBACL\fR
2628 mask are changed to the new permissions. Be aware that the new \fBACL\fR mask
2629 permissions can change the effective permissions for additional users and
2630 groups who have \fBACL\fR entries on the file. Use the \fBgetfacl\fR(1) or
2631 \fBls\fR(1)command to make sure the appropriate permissions are set for all