1 .\" $NetBSD: chmod.1,v 1.21 2005/12/09 20:27:02 wiz 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 utility modifies the file mode bits of the listed files
58 The options are as follows:
63 option is specified, symbolic links on the command line are followed.
64 (Symbolic links encountered in the tree traversal are not followed.)
68 option is specified, all symbolic links are followed.
72 option is specified, no symbolic links are followed.
74 Change the modes of the file hierarchies rooted in the files
75 instead of just the files themselves.
79 is symbolic link, the mode of the link is changed.
87 options are ignored unless the
90 In addition, these options override each other and the
91 command's actions are determined by the last one specified.
93 Only the owner of a file or the super-user is permitted to change
98 utility exits 0 on success, and \*[Gt]0 if an error occurs.
100 Modes may be absolute or symbolic.
101 An absolute mode is an octal number constructed by
103 the following values:
105 .Bl -tag -width 6n -compact -offset indent
107 set-user-ID-on-execution
109 set-group-ID-on-execution
118 execute (or search for directories) by owner
120 read, write, execute/search by group
122 read, write, execute/search by others
125 The read, write, and execute/search values for group and others
126 are encoded as described for owner.
128 The symbolic mode is described by the following grammar:
129 .Bd -literal -offset indent
130 mode ::= clause [, clause ...]
131 clause ::= [who ...] [action ...] last_action
132 action ::= op [perm ...]
133 last_action ::= op [perm ...]
134 who ::= a | u | g | o
136 perm ::= r | s | t | w | x | X | u | g | o
141 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
142 of the mode bits, respectively.
145 symbol ``a'' is equivalent to ``ugo''.
149 symbols represent the portions of the mode bits as follows:
151 .Bl -tag -width Ds -compact -offset indent
155 The set-user-ID-on-execution and set-group-ID-on-execution bits.
161 The execute/search bits.
163 The execute/search bits if the file is a directory or any of the
164 execute/search bits are set in the original (unmodified) mode.
167 symbol ``X'' are only meaningful in conjunction with the
169 symbol ``+'', and are ignored in all other cases.
171 The user permission bits in the mode of the original file.
173 The group permission bits in the mode of the original file.
175 The other permission bits in the mode of the original file.
180 symbols represent the operation performed, as follows:
183 If no value is supplied for
185 the ``+'' operation has no effect.
186 If no value is supplied for
188 each permission bit specified in
190 for which the corresponding bit in the file mode creation mask
192 Otherwise, the mode bits represented by the specified
198 If no value is supplied for
200 the ``\-'' operation has no effect.
201 If no value is supplied for
203 each permission bit specified in
205 for which the corresponding bit in the file mode creation mask
206 is clear, is cleared.
207 Otherwise, the mode bits represented by the specified
213 The mode bits specified by the
215 value are cleared, or, if no who value is specified, the owner, group
216 and other mode bits are cleared.
217 Then, if no value is supplied for
219 each permission bit specified in
221 for which the corresponding bit in the file mode creation mask
223 Otherwise, the mode bits represented by the specified
232 specifies one or more operations to be performed on the mode
233 bits, and each operation is applied to the mode bits in the
236 Operations upon the other permissions only (specified by the symbol
237 ``o'' by itself), in combination with the
239 symbols ``s'' or ``t'', are ignored.
241 .Bl -tag -width "u=rwx,go=u-w" -compact
243 make a file readable by anyone and writable by the owner only.
246 deny write permission to group and others.
249 set the read and write permissions to the usual defaults, but
250 retain any execute permissions that are currently set.
253 make a directory or file searchable/executable by everyone if it is
254 already searchable/executable by anyone.
259 make a file readable/executable by everyone and writable by the owner only.
262 clear all mode bits for group and others.
265 set the group bits equal to the user bits, but clear the group write bit.
280 utility is expected to be
282 compatible with the exception of the
286 which is not included in that standard.
290 option for the naughty bits.