1 .\" $NetBSD: chmod.1,v 1.24 2012/10/22 17:47:06 christos 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.
110 Only the owner of a file or the super-user is permitted to change
115 utility exits 0 on success, and \*[Gt]0 if an error occurs.
117 Modes may be absolute or symbolic.
118 An absolute mode is an octal number constructed by
120 the following values:
122 .Bl -tag -width 6n -compact -offset indent
124 set-user-ID-on-execution
126 set-group-ID-on-execution
135 execute (or search for directories) by owner
137 read, write, execute/search by group
139 read, write, execute/search by others
142 The read, write, and execute/search values for group and others
143 are encoded as described for owner.
145 The symbolic mode is described by the following grammar:
146 .Bd -literal -offset indent
147 mode ::= clause [, clause ...]
148 clause ::= [who ...] [action ...] last_action
149 action ::= op [perm ...]
150 last_action ::= op [perm ...]
151 who ::= a | u | g | o
153 perm ::= r | s | t | w | x | X | u | g | o
158 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
159 of the mode bits, respectively.
162 symbol ``a'' is equivalent to ``ugo''.
166 symbols represent the portions of the mode bits as follows:
168 .Bl -tag -width Ds -compact -offset indent
172 The set-user-ID-on-execution and set-group-ID-on-execution bits.
178 The execute/search bits.
180 The execute/search bits if the file is a directory or any of the
181 execute/search bits are set in the original (unmodified) mode.
184 symbol ``X'' are only meaningful in conjunction with the
186 symbol ``+'', and are ignored in all other cases.
188 The user permission bits in the mode of the original file.
190 The group permission bits in the mode of the original file.
192 The other permission bits in the mode of the original file.
197 symbols represent the operation performed, as follows:
200 If no value is supplied for
202 the ``+'' operation has no effect.
203 If no value is supplied for
205 each permission bit specified in
207 for which the corresponding bit in the file mode creation mask
209 Otherwise, the mode bits represented by the specified
215 If no value is supplied for
217 the ``\-'' operation has no effect.
218 If no value is supplied for
220 each permission bit specified in
222 for which the corresponding bit in the file mode creation mask
223 is clear, is cleared.
224 Otherwise, the mode bits represented by the specified
230 The mode bits specified by the
232 value are cleared, or, if no who value is specified, the owner, group
233 and other mode bits are cleared.
234 Then, if no value is supplied for
236 each permission bit specified in
238 for which the corresponding bit in the file mode creation mask
240 Otherwise, the mode bits represented by the specified
249 specifies one or more operations to be performed on the mode
250 bits, and each operation is applied to the mode bits in the
253 Operations upon the other permissions only (specified by the symbol
254 ``o'' by itself), in combination with the
256 symbols ``s'' or ``t'', are ignored.
258 .Bl -tag -width "u=rwx,go=u-w" -compact
260 make a file readable by anyone and writable by the owner only.
263 deny write permission to group and others.
266 set the read and write permissions to the usual defaults, but
267 retain any execute permissions that are currently set.
270 make a directory or file searchable/executable by everyone if it is
271 already searchable/executable by anyone.
276 make a file readable/executable by everyone and writable by the owner only.
279 clear all mode bits for group and others.
282 set the group bits equal to the user bits, but clear the group write bit.
297 utility is expected to be
299 compatible with the exception of the
303 which is not included in that standard.
307 option for the naughty bits.