1 .\" $NetBSD: chmod.1,v 1.26 2016/08/11 00:10:42 sevan Exp $
3 .\" Copyright (c) 1989, 1990, 1993, 1994
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the Institute of Electrical and Electronics Engineers, Inc.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\" may be used to endorse or promote products derived from this software
19 .\" without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
45 .Op Fl H | Fl L | Fl P
53 .Op Fl H | Fl L | Fl P
56 .Fl Fl reference=rfile
61 utility modifies the file mode bits of the listed files
65 copied from a reference
71 The options are as follows:
76 option is specified, symbolic links on the command line are followed.
77 (Symbolic links encountered in the tree traversal are not followed.)
81 option is specified, all symbolic links are followed.
85 option is specified, no symbolic links are followed.
87 Change the modes of the file hierarchies rooted in the files
88 instead of just the files themselves.
90 Do not display a diagnostic message or modify the exit status if
92 fails to change the mode of a file.
96 is symbolic link, the mode of the link is changed.
104 options are ignored unless the
107 In addition, these options override each other and the
108 command's actions are determined by the last one specified.
109 The default is as if the
111 option had been specified.
113 Only the owner of a file or the super-user is permitted to change
118 utility exits 0 on success, and \*[Gt]0 if an error occurs.
120 Modes may be absolute or symbolic.
121 An absolute mode is an octal number constructed by
123 the following values:
125 .Bl -tag -width 6n -compact -offset indent
127 set-user-ID-on-execution
129 set-group-ID-on-execution
138 execute (or search for directories) by owner
140 read, write, execute/search by group
142 read, write, execute/search by others
145 The read, write, and execute/search values for group and others
146 are encoded as described for owner.
148 The symbolic mode is described by the following grammar:
149 .Bd -literal -offset indent
150 mode ::= clause [, clause ...]
151 clause ::= [who ...] [action ...] last_action
152 action ::= op [perm ...]
153 last_action ::= op [perm ...]
154 who ::= a | u | g | o
156 perm ::= r | s | t | w | x | X | u | g | o
161 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
162 of the mode bits, respectively.
165 symbol ``a'' is equivalent to ``ugo''.
169 symbols represent the portions of the mode bits as follows:
171 .Bl -tag -width Ds -compact -offset indent
175 The set-user-ID-on-execution and set-group-ID-on-execution bits.
181 The execute/search bits.
183 The execute/search bits if the file is a directory or any of the
184 execute/search bits are set in the original (unmodified) mode.
187 symbol ``X'' are only meaningful in conjunction with the
189 symbol ``+'', and are ignored in all other cases.
191 The user permission bits in the mode of the original file.
193 The group permission bits in the mode of the original file.
195 The other permission bits in the mode of the original file.
200 symbols represent the operation performed, as follows:
203 If no value is supplied for
205 the ``+'' operation has no effect.
206 If no value is supplied for
208 each permission bit specified in
210 for which the corresponding bit in the file mode creation mask
212 Otherwise, the mode bits represented by the specified
218 If no value is supplied for
220 the ``\-'' operation has no effect.
221 If no value is supplied for
223 each permission bit specified in
225 for which the corresponding bit in the file mode creation mask
226 is clear, is cleared.
227 Otherwise, the mode bits represented by the specified
233 The mode bits specified by the
235 value are cleared, or, if no who value is specified, the owner, group
236 and other mode bits are cleared.
237 Then, if no value is supplied for
239 each permission bit specified in
241 for which the corresponding bit in the file mode creation mask
243 Otherwise, the mode bits represented by the specified
252 specifies one or more operations to be performed on the mode
253 bits, and each operation is applied to the mode bits in the
256 Operations upon the other permissions only (specified by the symbol
257 ``o'' by itself), in combination with the
259 symbols ``s'' or ``t'', are ignored.
261 .Bl -tag -width "u=rwx,go=u-w" -compact
263 make a file readable by anyone and writable by the owner only.
266 deny write permission to group and others.
269 set the read and write permissions to the usual defaults, but
270 retain any execute permissions that are currently set.
273 make a directory or file searchable/executable by everyone if it is
274 already searchable/executable by anyone.
279 make a file readable/executable by everyone and writable by the owner only.
282 clear all mode bits for group and others.
285 set the group bits equal to the user bits, but clear the group write bit.
300 utility is expected to be
302 compatible with the exception of the
306 which is not included in that standard.
315 option for the naughty bits.