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. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
49 .Op Fl H | Fl L | Fl P
57 utility modifies the file mode bits of the listed files
62 The options are as follows:
67 option is specified, symbolic links on the command line are followed.
68 (Symbolic links encountered in the tree traversal are not followed.)
72 option is specified, all symbolic links are followed.
76 option is specified, no symbolic links are followed.
78 Change the modes of the file hierarchies rooted in the files
79 instead of just the files themselves.
81 Do not display a diagnostic message if
83 could not modify the mode for
87 to be verbose, showing files as the mode is modified.
91 Symbolic links do not have modes, so unless the
97 on a symbolic link always succeeds and has no effect.
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.
109 Only the owner of a file or the super-user is permitted to change
114 utility exits 0 on success, and >0 if an error occurs.
116 Modes may be absolute or symbolic.
117 An absolute mode is an octal number constructed from the sum of
118 one or more of the following values:
120 .Bl -tag -width 6n -compact -offset indent
122 (the set-user-ID-on-execution bit) Executable files with this bit set
123 will run with effective uid set to the uid of the file owner.
124 Directories with the set-user-id bit set will force all files and
125 sub-directories created in them to be owned by the directory owner
126 and not by the uid of the creating process, if the underlying file
127 system supports this feature: see
134 (the set-group-ID-on-execution bit) Executable files with this bit set
135 will run with effective gid set to the gid of the file owner.
138 When set on a directory, unprivileged users can delete and rename
139 only those files in the directory that are owned by them, regardless of
140 the permissions on the directory. Under FreeBSD, the sticky bit is
141 ignored for executable files and may only be set for directories (see
146 Allow write by owner.
148 For files, allow execution by owner. For directories, allow the owner to
149 search in the directory.
151 Allow read by group members.
153 Allow write by group members.
155 For files, allow execution by group members. For directories, allow
156 group members to search in the directory.
158 Allow read by others.
160 Allow write by others.
162 For files, allow execution by others. For directories allow others to
163 search in the directory.
166 For example, the absolute mode that permits read, write and execute by
167 the owner, read and execute by group members, read and execute by
168 others, and no set-uid or set-gid behaviour is 755
169 (400+200+100+040+010+004+001).
171 The symbolic mode is described by the following grammar:
172 .Bd -literal -offset indent
173 mode ::= clause [, clause ...]
174 clause ::= [who ...] [action ...] last_action
175 action ::= op [perm ...]
176 last_action ::= op [perm ...]
177 who ::= a | u | g | o
179 perm ::= r | s | t | w | x | X | u | g | o
184 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
185 of the mode bits, respectively.
188 symbol ``a'' is equivalent to ``ugo''.
193 symbols represent the portions of the mode bits as follows:
195 .Bl -tag -width Ds -compact -offset indent
199 The set-user-ID-on-execution and set-group-ID-on-execution bits.
205 The execute/search bits.
207 The execute/search bits if the file is a directory or any of the
208 execute/search bits are set in the original (unmodified) mode.
211 symbol ``X'' are only meaningful in conjunction with the
213 symbol ``+'', and are ignored in all other cases.
215 The user permission bits in the mode of the original file.
217 The group permission bits in the mode of the original file.
219 The other permission bits in the mode of the original file.
224 symbols represent the operation performed, as follows:
227 If no value is supplied for
229 the ``+'' operation has no effect.
230 If no value is supplied for
232 each permission bit specified in
234 for which the corresponding bit in the file mode creation mask
236 Otherwise, the mode bits represented by the specified
242 If no value is supplied for
244 the ``\-'' operation has no effect.
245 If no value is supplied for
247 each permission bit specified in
249 for which the corresponding bit in the file mode creation mask
250 is clear, is cleared.
251 Otherwise, the mode bits represented by the specified
257 The mode bits specified by the
259 value are cleared, or, if no who value is specified, the owner, group
260 and other mode bits are cleared.
261 Then, if no value is supplied for
263 each permission bit specified in
265 for which the corresponding bit in the file mode creation mask
267 Otherwise, the mode bits represented by the specified
276 specifies one or more operations to be performed on the mode
277 bits, and each operation is applied to the mode bits in the
280 Operations upon the other permissions only (specified by the symbol
281 ``o'' by itself), in combination with the
283 symbols ``s'' or ``t'', are ignored.
285 .Bl -tag -width "u=rwx,go=u-w" -compact
287 make a file readable by anyone and writable by the owner only.
290 deny write permission to group and others.
293 set the read and write permissions to the usual defaults, but
294 retain any execute permissions that are currently set.
297 make a directory or file searchable/executable by everyone if it is
298 already searchable/executable by anyone.
303 make a file readable/executable by everyone and writable by the owner only.
306 clear all mode bits for group and others.
309 set the group bits equal to the user bits, but clear the group write bit.
314 option for the naughty bits.
318 option is non-standard and its use in scripts is not recommended.
334 utility is expected to be
336 compatible with the exception of the
342 which are not included in that standard.