2 .\" Copyright (c) 1989, 1990, 1993, 1994
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Institute of Electrical and Electronics Engineers, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
44 .Op Fl R Op Fl H | L | P
50 utility modifies the file mode bits of the listed files
55 The options are as follows:
56 .Bl -tag -width indent
58 Do not display a diagnostic message if
60 could not modify the mode for
62 nor modify the exit status to reflect such failures.
66 option is specified, symbolic links on the command line are followed
67 and hence unaffected by the command.
68 (Symbolic links encountered during tree traversal are not followed.)
70 If the file is a symbolic link, change the mode of the link itself
71 rather than the file that the link points to.
75 option is specified, all symbolic links are followed.
79 option is specified, no symbolic links are followed.
82 Change the modes of the file hierarchies rooted in the files,
83 instead of just the files themselves.
84 Beware of unintentionally matching the
86 hard link to the parent directory when using wildcards like
91 to be verbose, showing filenames as the mode is modified.
94 flag is specified more than once, the old and new modes of the file
95 will also be printed, in both octal and symbolic notation.
103 options are ignored unless the
106 In addition, these options override each other and the
107 command's actions are determined by the last one specified.
117 then the current filename as well as the old and new modes are displayed.
119 Only the owner of a file or the super-user is permitted to change
124 Modes may be absolute or symbolic.
125 An absolute mode is an octal number constructed from the sum of
126 one or more of the following values:
128 .Bl -tag -width 6n -compact -offset indent
131 Executable files with this bit set
132 will run with effective uid set to the uid of the file owner.
133 Directories with this bit set will force all files and
134 sub-directories created in them to be owned by the directory owner
135 and not by the uid of the creating process, if the underlying file
136 system supports this feature: see
144 Executable files with this bit set
145 will run with effective gid set to the gid of the file owner.
155 Allow write by owner.
157 For files, allow execution by owner.
158 For directories, allow the owner to
159 search in the directory.
161 Allow read by group members.
163 Allow write by group members.
165 For files, allow execution by group members.
166 For directories, allow
167 group members to search in the directory.
169 Allow read by others.
171 Allow write by others.
173 For files, allow execution by others.
174 For directories allow others to
175 search in the directory.
178 For example, the absolute mode that permits read, write and execute by
179 the owner, read and execute by group members, read and execute by
180 others, and no set-uid or set-gid behaviour is 755
181 (400+200+100+040+010+004+001).
183 The symbolic mode is described by the following grammar:
184 .Bd -literal -offset indent
185 mode ::= clause [, clause ...]
186 clause ::= [who ...] [action ...] action
187 action ::= op [perm ...]
188 who ::= a | u | g | o
190 perm ::= r | s | t | w | x | X | u | g | o
195 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
196 of the mode bits, respectively.
199 symbol ``a'' is equivalent to ``ugo''.
203 symbols represent the portions of the mode bits as follows:
205 .Bl -tag -width Ds -compact -offset indent
209 The set-user-ID-on-execution and set-group-ID-on-execution bits.
215 The execute/search bits.
217 The execute/search bits if the file is a directory or any of the
218 execute/search bits are set in the original (unmodified) mode.
221 symbol ``X'' are only meaningful in conjunction with the
223 symbol ``+'', and are ignored in all other cases.
225 The user permission bits in the original mode of the file.
227 The group permission bits in the original mode of the file.
229 The other permission bits in the original mode of the file.
234 symbols represent the operation performed, as follows:
237 If no value is supplied for
239 the ``+'' operation has no effect.
240 If no value is supplied for
242 each permission bit specified in
244 for which the corresponding bit in the file mode creation mask
248 Otherwise, the mode bits represented by the specified
254 If no value is supplied for
256 the ``\-'' operation has no effect.
257 If no value is supplied for
259 each permission bit specified in
261 for which the corresponding bit in the file mode creation mask
262 is clear, is cleared.
263 Otherwise, the mode bits represented by the specified
269 The mode bits specified by the
271 value are cleared, or, if no
273 value is specified, the owner, group
274 and other mode bits are cleared.
275 Then, if no value is supplied for
277 each permission bit specified in
279 for which the corresponding bit in the file mode creation mask
281 Otherwise, the mode bits represented by the specified
290 specifies one or more operations to be performed on the mode
291 bits, and each operation is applied to the mode bits in the
294 Operations upon the other permissions only (specified by the symbol
295 ``o'' by itself), in combination with the
297 symbols ``s'' or ``t'', are ignored.
299 The ``w'' permission on directories will permit file creation, relocation,
300 and copy into that directory.
301 Files created within the directory itself will inherit its group ID.
303 .Bl -tag -width "u=rwx,go=u-w" -compact
305 make a file readable by anyone and writable by the owner only.
308 deny write permission to group and others.
311 set the read and write permissions to the usual defaults, but
312 retain any execute permissions that are currently set.
315 make a directory or file searchable/executable by everyone if it is
316 already searchable/executable by anyone.
321 make a file readable/executable by everyone and writable by the owner only.
324 clear all mode bits for group and others.
327 set the group bits equal to the user bits, but clear the group write bit.
332 option is non-standard and its use in scripts is not recommended.
349 utility is expected to be
351 compatible with the exception of the
355 which is not included in that standard.
364 option for the naughty bits of a horse.