snj doesn't like my accent, so use proper English month names.
[netbsd-mini2440.git] / bin / chmod / chmod.1
blobc65b485f0281227c472e666ebb80428547e67193
1 .\"     $NetBSD: chmod.1,v 1.21 2005/12/09 20:27:02 wiz Exp $
2 .\"
3 .\" Copyright (c) 1989, 1990, 1993, 1994
4 .\"     The Regents of the University of California.  All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the Institute of Electrical and Electronics Engineers, Inc.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
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.
20 .\"
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
31 .\" SUCH DAMAGE.
32 .\"
33 .\"     @(#)chmod.1     8.4 (Berkeley) 3/31/94
34 .\"
35 .Dd December 9, 2005
36 .Dt CHMOD 1
37 .Os
38 .Sh NAME
39 .Nm chmod
40 .Nd change file modes
41 .Sh SYNOPSIS
42 .Nm
43 .Oo
44 .Fl R
45 .Op Fl H | Fl L | Fl P
46 .Oc
47 .Op Fl h
48 .Ar mode
49 .Ar
50 .Sh DESCRIPTION
51 The
52 .Nm
53 utility modifies the file mode bits of the listed files
54 as specified by the
55 .Ar mode
56 operand.
57 .Pp
58 The options are as follows:
59 .Bl -tag -width Ds
60 .It Fl H
61 If the
62 .Fl R
63 option is specified, symbolic links on the command line are followed.
64 (Symbolic links encountered in the tree traversal are not followed.)
65 .It Fl L
66 If the
67 .Fl R
68 option is specified, all symbolic links are followed.
69 .It Fl P
70 If the
71 .Fl R
72 option is specified, no symbolic links are followed.
73 .It Fl R
74 Change the modes of the file hierarchies rooted in the files
75 instead of just the files themselves.
76 .It Fl h
78 .Ar file
79 is symbolic link, the mode of the link is changed.
80 .El
81 .Pp
82 The
83 .Fl H ,
84 .Fl L
85 and
86 .Fl P
87 options are ignored unless the
88 .Fl R
89 option is specified.
90 In addition, these options override each other and the
91 command's actions are determined by the last one specified.
92 .Pp
93 Only the owner of a file or the super-user is permitted to change
94 the mode of a file.
95 .Sh EXIT STATUS
96 The
97 .Nm
98 utility exits 0 on success, and \*[Gt]0 if an error occurs.
99 .Sh MODES
100 Modes may be absolute or symbolic.
101 An absolute mode is an octal number constructed by
102 .Em or Ap ing
103 the following values:
105 .Bl -tag -width 6n -compact -offset indent
106 .It Li 4000
107 set-user-ID-on-execution
108 .It Li 2000
109 set-group-ID-on-execution
110 .It Li 1000
111 sticky bit, see
112 .Xr chmod 2
113 .It Li 0400
114 read by owner
115 .It Li 0200
116 write by owner
117 .It Li 0100
118 execute (or search for directories) by owner
119 .It Li 0070
120 read, write, execute/search by group
121 .It Li 0007
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
135 op           ::= + | \- | =
136 perm         ::= r | s | t | w | x | X | u | g | o
140 .Ar who
141 symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
142 of the mode bits, respectively.
144 .Ar who
145 symbol ``a'' is equivalent to ``ugo''.
148 .Ar perm
149 symbols represent the portions of the mode bits as follows:
151 .Bl -tag -width Ds -compact -offset indent
152 .It r
153 The read bits.
154 .It s
155 The set-user-ID-on-execution and set-group-ID-on-execution bits.
156 .It t
157 The sticky bit.
158 .It w
159 The write bits.
160 .It x
161 The execute/search bits.
162 .It X
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.
165 Operations with the
166 .Ar perm
167 symbol ``X'' are only meaningful in conjunction with the
168 .Ar op
169 symbol ``+'', and are ignored in all other cases.
170 .It u
171 The user permission bits in the mode of the original file.
172 .It g
173 The group permission bits in the mode of the original file.
174 .It o
175 The other permission bits in the mode of the original file.
179 .Ar op
180 symbols represent the operation performed, as follows:
181 .Bl -tag -width 4n
182 .It +
183 If no value is supplied for
184 .Ar perm ,
185 the ``+'' operation has no effect.
186 If no value is supplied for
187 .Ar who ,
188 each permission bit specified in
189 .Ar perm ,
190 for which the corresponding bit in the file mode creation mask
191 is clear, is set.
192 Otherwise, the mode bits represented by the specified
193 .Ar who
195 .Ar perm
196 values are set.
197 .It \&\-
198 If no value is supplied for
199 .Ar perm ,
200 the ``\-'' operation has no effect.
201 If no value is supplied for
202 .Ar who ,
203 each permission bit specified in
204 .Ar perm ,
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
208 .Ar who
210 .Ar perm
211 values are cleared.
212 .It =
213 The mode bits specified by the
214 .Ar who
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
218 .Ar who ,
219 each permission bit specified in
220 .Ar perm ,
221 for which the corresponding bit in the file mode creation mask
222 is clear, is set.
223 Otherwise, the mode bits represented by the specified
224 .Ar who
226 .Ar perm
227 values are set.
230 Each
231 .Ar clause
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
234 order specified.
236 Operations upon the other permissions only (specified by the symbol
237 ``o'' by itself), in combination with the
238 .Ar perm
239 symbols ``s'' or ``t'', are ignored.
240 .Sh EXAMPLES
241 .Bl -tag -width "u=rwx,go=u-w" -compact
242 .It Li 644
243 make a file readable by anyone and writable by the owner only.
245 .It Li go-w
246 deny write permission to group and others.
248 .It Li =rw,+X
249 set the read and write permissions to the usual defaults, but
250 retain any execute permissions that are currently set.
252 .It Li +X
253 make a directory or file searchable/executable by everyone if it is
254 already searchable/executable by anyone.
256 .It Li 755
257 .It Li u=rwx,go=rx
258 .It Li u=rwx,go=u-w
259 make a file readable/executable by everyone and writable by the owner only.
261 .It Li go=
262 clear all mode bits for group and others.
264 .It Li g=u-w
265 set the group bits equal to the user bits, but clear the group write bit.
267 .Sh SEE ALSO
268 .Xr chflags 1 ,
269 .Xr install 1 ,
270 .Xr chmod 2 ,
271 .Xr stat 2 ,
272 .Xr umask 2 ,
273 .Xr fts 3 ,
274 .Xr setmode 3 ,
275 .Xr symlink 7 ,
276 .Xr chown 8
277 .Sh STANDARDS
280 utility is expected to be
281 .St -p1003.2-92
282 compatible with the exception of the
283 .Ar perm
284 symbol
285 .Dq t
286 which is not included in that standard.
287 .Sh BUGS
288 There's no
289 .Ar perm
290 option for the naughty bits.