1 .\" Copyright (c) 1989, 1990, 1993, 1994
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the Institute of Electrical and Electronics Engineers, Inc.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
32 .\" $FreeBSD: src/bin/chmod/chmod.1,v 1.17.2.16 2003/02/24 03:01:00 trhodes Exp $
33 .\" $DragonFly: src/bin/chmod/chmod.1,v 1.3 2006/02/17 19:33:30 swildner Exp $
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 (Symbolic links encountered in the tree traversal are not followed by
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.
87 to be verbose, showing filenames as the mode is modified.
95 options are ignored unless the
98 In addition, these options override each other and the
99 command's actions are determined by the last one specified.
101 Only the owner of a file or the super-user is permitted to change
106 .Bl -tag -width "u=rwx,go=u-w" -compact
108 make a file readable by anyone and writable by the owner only.
111 deny write permission to group and others.
114 set the read and write permissions to the usual defaults, but
115 retain any execute permissions that are currently set.
118 make a directory or file searchable/executable by everyone if it is
119 already searchable/executable by anyone.
124 make a file readable/executable by everyone and writable by the owner only.
127 clear all mode bits for group and others.
130 set the group bits equal to the user bits, but clear the group write bit.
133 Modes may be absolute or symbolic.
134 An absolute mode is an octal number constructed from the sum of
135 one or more of the following values:
137 .Bl -tag -width 6n -compact -offset indent
140 Executable files with this bit set
141 will run with effective uid set to the uid of the file owner.
142 Directories with this bit set will force all files and
143 sub-directories created in them to be owned by the directory owner
144 and not by the uid of the creating process, if the underlying file
145 system supports this feature: see
153 Executable files with this bit set
154 will run with effective gid set to the gid of the file owner.
164 Allow write by owner.
166 For files, allow execution by owner.
167 For directories, allow the owner to
168 search in the directory.
170 Allow read by group members.
172 Allow write by group members.
174 For files, allow execution by group members.
175 For directories, allow
176 group members to search in the directory.
178 Allow read by others.
180 Allow write by others.
182 For files, allow execution by others.
183 For directories allow others to
184 search in the directory.
187 For example, the absolute mode that permits read, write and execute by
188 the owner, read and execute by group members, read and execute by
189 others, and no set-uid or set-gid behaviour is 755
190 (400+200+100+040+010+004+001).
192 The symbolic mode is described by the following grammar:
193 .Bd -literal -offset indent
194 mode ::= clause [, clause ...]
195 clause ::= [who ...] [action ...] action
196 action ::= op [perm ...]
197 who ::= a | u | g | o
199 perm ::= r | s | t | w | x | X | u | g | o
204 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
205 of the mode bits, respectively.
208 symbol ``a'' is equivalent to ``ugo''.
212 symbols represent the portions of the mode bits as follows:
214 .Bl -tag -width Ds -compact -offset indent
218 The set-user-ID-on-execution and set-group-ID-on-execution bits.
224 The execute/search bits.
226 The execute/search bits if the file is a directory or any of the
227 execute/search bits are set in the original (unmodified) mode.
230 symbol ``X'' are only meaningful in conjunction with the
232 symbol ``+'', and are ignored in all other cases.
234 The user permission bits in the original mode of the file.
236 The group permission bits in the original mode of the file.
238 The other permission bits in the original mode of the file.
243 symbols represent the operation performed, as follows:
246 If no value is supplied for
248 the ``+'' operation has no effect.
249 If no value is supplied for
251 each permission bit specified in
253 for which the corresponding bit in the file mode creation mask
255 Otherwise, the mode bits represented by the specified
261 If no value is supplied for
263 the ``\-'' operation has no effect.
264 If no value is supplied for
266 each permission bit specified in
268 for which the corresponding bit in the file mode creation mask
269 is clear, is cleared.
270 Otherwise, the mode bits represented by the specified
276 The mode bits specified by the
278 value are cleared, or, if no who value is specified, the owner, group
279 and other mode bits are cleared.
280 Then, if no value is supplied for
282 each permission bit specified in
284 for which the corresponding bit in the file mode creation mask
286 Otherwise, the mode bits represented by the specified
295 specifies one or more operations to be performed on the mode
296 bits, and each operation is applied to the mode bits in the
299 Operations upon the other permissions only (specified by the symbol
300 ``o'' by itself), in combination with the
302 symbols ``s'' or ``t'', are ignored.
306 option is non-standard and its use in scripts is not recommended.
322 utility is expected to be
324 compatible with the exception of the
328 which is not included in that standard.
337 option for the naughty bits.