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.
1090 \fBsuccessful_access (\fBS\fR)\fR
1093 Indicates whether an alarm or audit record should be initiated upon successful
1094 accesses. Used with audit/alarm ACE types.
1100 \fBfailed_access (\fBF\fR)\fR
1103 Indicates whether an alarm or audit record should be initiated when access
1104 fails. Used with audit/alarm ACE types.
1110 \fBinherited (\fBI\fR)\fR
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.
1129 file_inherit/dir_inherit/no_propagate
1152 With this inheritance model, an ACL entry can be specified such as:
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
1163 .SS "Attribute Operation"
1165 An attribute operation command line has the following format:
1169 chmod [\fIoptions\fR] \fIattribute_specification_list\fR \fIfile\fR ...
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:
1182 [\fIoperator\fR]\fIattribute_specifier\fR
1189 An \fIoperator\fR is one of the following:
1196 Each attribute specified by the associated \fIattribute_specifier\fR is
1197 adjusted to match the value specified by the \fIattribute_specifier\fR.
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.
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:
1237 Set all boolean read-write extended system attributes associated with the
1244 \fB\fBc[\fIcompact_attribute_list\fR]\fR\fR
1248 \fB\fBc'{'\fIcompact_attribute_list\fR'}'\fR\fR
1252 Set each boolean read-write extended system attribute identified by
1253 \fIcompact_attribute_list\fR.
1259 \fB\fBv[\fIverbose_attribute_setting\fR]\fR\fR
1263 \fB\fBv['{'\fIverbose_attribute_setting_list\fR'}']\fR\fR
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
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:
1300 \fB\fBAttribute Name\fR\fR
1303 \fBAbbreviation Character\fR
1327 \fB\fBreadonly\fR\fR
1345 \fB\fBnounlink\fR\fR
1354 \fB\fBimmutable\fR\fR
1363 \fB\fBappendonly\fR\fR
1381 \fB\fBav_quarantined\fR\fR
1390 \fB\fBav_modified\fR\fR
1416 The following options are supported:
1423 Force. \fBchmod\fR does not complain if it fails to change the mode of a file.
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.
1440 \fB\fB-@\fR \fInamed_attribute\fR\fR
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.
1460 The following operands are supported:
1464 \fB\fIabsolute-mode\fR\fR
1468 \fB\fIsymbolic-mode-list\fR\fR
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.
1480 \fB\fIacl_operation\fR\fR
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:
1491 \fBA[\fR\fInumber\fR\fB] -\fR
1492 \fBA-\fR\fIacl_specification\fR
1493 \fBA[\fR\fIindex\fR\fB]{+|=}\fR\fBacl_specification\fR
1503 \fB\fIattribute_specification_list\fR\fR
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
1519 A path name of a file whose file mode bits are to be modified.
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).
1528 \fBExample 1 \fRDenying \fBexecute\fR Permission
1531 The following example denies execute permission to everyone:
1536 % chmod a-x \fIfile\fR
1542 \fBExample 2 \fRAllowing \fBread-only\fR Permission
1545 The following example allows only read permission to everyone:
1550 % chmod 444 \fIfile\fR
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
1565 % chmod go+rw \fIfile\fR
1566 % chmod 066 \fIfile\fR
1572 \fBExample 4 \fRLocking a File From Access
1575 The following example locks a file from access:
1580 $ chmod +l \fIfile\fR
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:
1596 $ chmod a=rwx,g+s \fIfile\fR
1597 $ chmod 2777 \fIfile\fR
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:
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/
1632 Issue the following command:
1637 $ chmod A+user:lp:read_data:deny file.3
1644 Display the new ACL:
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/
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:
1679 -rw-r--r-- 1 marks staff 0 Oct 9 15:52 file.2
1681 1:group::r-- #effective:r--
1690 Issue the following command:
1695 $ chmod A+user:lp:-wx file.2
1702 Display the new ACL:
1708 -rw-r--r--+ 1 marks staff 0 Oct 9 15:52 file.2
1710 1:user:lp:-wx #effective:---
1711 2:group::r-- #effective:r--
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.
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
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:
1757 $ chmod A3+user:marks:r:deny file.1
1764 Display the new ACL:
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
1784 \fBExample 9 \fRInserting a POSIX-draft ACL in a Specific Position on a UFS
1788 The file system reorders ACLs when they are stored in the file system. The
1789 following example illustrates this behavior.
1795 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1797 1:user:lp:rw- #effective:r--
1798 2:group::r-- #effective:r--
1807 Now, insert an entry at index position 3. The command works, but the file
1808 system reorders the ACL.
1813 $ chmod A3+user:marks:rw- file.1
1815 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1817 1:user:lp:rw- #effective:r--
1818 2:user:marks:rw- #effective:r--
1819 3:group::r-- #effective:r--
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:
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/
1859 $ chmod A-user:lp:read_data:deny 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/
1876 \fBExample 11 \fRRemoving a POSIX-draft ACL on a UFS File
1879 The following example removes the \fBlp\fR entry from an ACL:
1885 -rw-r--r--+ 1 marks staff 0 Oct 9 15:52 file.2
1887 1:user:lp:-wx #effective:---
1888 2:group::r-- #effective:r--
1898 $ chmod A-user:lp:-wx file.2
1900 -rw-r--r-- 1 marks staff 0 Oct 9 15:52 file.2
1902 1:group::r-- #effective:r--
1910 \fBExample 12 \fRRemoving a Specific ACL Entry by Index Number on a ZFS File
1913 Consider the following ACL:
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
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
1937 Remove the second user entry for bin.
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
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
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
1970 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1972 1:user:lp:rw- #effective:r--
1973 2:group::r-- #effective:r--
1979 -rw-r--r--+ 1 root root 0 Sep 29 16:10 file.1
1981 1:group::r-- #effective:r--
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:
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/
2020 The existing ACL is effectively removed and is replaced with an ACL that
2021 represents the permission bits of the file.
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/
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
2052 $ chmod A=owner@:read_data/write_data:allow,group@:read_data/
2053 write_data:allow,user:lp:read_data:allow 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
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.
2074 $ chmod A=user::rw-,group::rw-,other::---,mask:r--,
2077 -rw-r-----+ 1 root root 0 Oct 9 16:14 file.3
2079 1:user:lp:r-- #effective:r--
2080 2:group::rw- #effective:r--
2088 \fBExample 17 \fRReplacing a Specific Entry on a ZFS File
2091 Consider the following ACL.
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/
2114 Now, change the allow access to a deny for user marks:
2119 $ chmod A0=user:marks:read_data:deny 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
2136 \fBExample 18 \fRReplacing a Specific POSIX-draft ACL on a UFS File
2139 Consider the following ACL.
2145 -rw-r--r--+ 1 marks staff 0 Oct 9 16:21 file.4
2147 1:user:lp:rwx #effective:r--
2148 2:group::r-- #effective:r--
2157 Now, change the permission on \fBlp\fR from \fBrwx\fR to \fBr--\fR:
2162 $ chmod A1=user:lp:r-- file.4
2165 -rw-r--r--+ 1 marks staff 0 Oct 9 16:21 file.4
2167 1:user:lp:r-- #effective:r--
2168 2:group::r-- #effective:r--
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:
2191 $ chmod A+user:lp:read_data:file_inherit:allow 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
2196 2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
2197 /append_data/write_xattr/execute/write_attributes/write_acl
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
2211 The \fBlp\fR entry is inherited to newly created files in the directory
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
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/
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:
2245 $ chmod A+user:lp:read_data:file_inherit/\e
2246 dir_inherit:allow test.dir
2252 \fBExample 20 \fRReplacing System Attributes of a ZFS File
2255 The following examples replace system attributes of a ZFS file:
2260 $ chmod S=v{archive,hidden,readonly,system,appendonly,\e
2261 nonodump,immutable,noav_modified,noav_quarantined,\e
2262 nounlink,nooffline,nosparse} file1
2274 $ chmod S=c{AHRSaiu} file1
2286 $ chmod S=c{AHRSa-i--u--} file1
2298 $ chmod S=cAHRSaiu file1
2310 $ chmod -@ '..' S=cAHRSaiu file1
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:
2345 $ chmod -@ '..' S-a file1
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
2360 The following example sets a system attribute of a named attribute file of a
2361 ZFS file, but not of the file itself:
2366 $ chmod -@ myattr S+vhidden file1
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
2381 The following example sets a system attribute of all named attribute files of a
2382 ZFS file, but not of the file itself:
2387 $ chmod -@ '*' S+a file1
2393 \fBExample 24 \fRSetting a System Attribute of All Named Attribute Files of a
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:
2403 $ chmod -@ '..' -@ '*' S+vhidden file1
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:
2424 $ chmod -R -@ '..' -@ '*' S+a directory1
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
2440 The following examples set the \fBhidden\fR and \fBsystem\fR system attributes
2458 $ chmod S+vhidden,+vsystem file1
2470 $ chmod S+v{hidden,system} file1
2482 $ chmod S+c{-H-S--------} file1
2494 $ chmod S-v{nohidden,nosystem} file1
2506 $ chmod S-v{hidden,system},+v{hidden,system} file1
2512 \fBExample 27 \fRClearing All System Attributes of a ZFS File
2515 The following example clears all system attributes of a ZFS file:
2539 In the following two examples, the last attribute operation specified takes
2544 In this example, the replacement attribute name list (\fB{}\fR) clears all
2545 system attributes for \fBfile1\fR:
2550 $ chmod S+cHS,=v{} file1
2557 In this example, the clear attributes operation (\fB-a\fR) clears all system
2558 attributes of \fBfile1\fR:
2563 $ chmod S+vhidden,+vsystem,-a file1
2569 \fBExample 28 \fRSetting the Values of All Boolean read-write System Attributes
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
2580 $ chmod S=v`ls -/v file1|sed -n '2s/.*{/{/p'` file2
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.
2599 The following exit values are returned:
2606 Successful completion.
2620 See \fBattributes\fR(5) for descriptions of the following attributes:
2628 ATTRIBUTE TYPE ATTRIBUTE VALUE
2632 Interface Stability Committed
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)
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