Commit | Line | Data |
---|---|---|
7b089094 WJ |
1 | .\" Copyright (c) 1989, 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
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. | |
22 | .\" | |
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 | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
35 | .\" @(#)chmod.1 6.15 (Berkeley) 7/23/91 | |
36 | .\" | |
37 | .Dd July 23, 1991 | |
38 | .Dt CHMOD 1 | |
39 | .Os | |
40 | .Sh NAME | |
41 | .Nm chmod | |
42 | .Nd change file modes | |
43 | .Sh SYNOPSIS | |
44 | .Nm chmod | |
45 | .Op Fl R | |
46 | .Ar mode | |
47 | .Ar file ... | |
48 | .Sh DESCRIPTION | |
49 | The | |
50 | .Nm chmod | |
51 | utility modifies the file mode bits of the listed files | |
52 | as specified by the | |
53 | .Ar mode | |
54 | operand. | |
55 | .Pp | |
56 | The options are as follows: | |
57 | .Bl -tag -width Ds | |
58 | .It Fl R | |
59 | Traverse a file hierarchy. | |
60 | For each file that is of type directory, | |
61 | .Nm chmod | |
62 | changes the mode of all files in the file hierarchy below it followed | |
63 | by the mode of the directory itself. | |
64 | .El | |
65 | .Pp | |
66 | Symbolic links are not indirected through, nor are their modes altered. | |
67 | .Pp | |
68 | Only the owner of a file or the super-user is permitted to change | |
69 | the mode of a file. | |
70 | .Pp | |
71 | The | |
72 | .Nm chmod | |
73 | utility exits 0 on success, and >0 if an error occurs. | |
74 | .Sh MODES | |
75 | Modes may be absolute or symbolic. | |
76 | An absolute mode is an octal number constructed by | |
77 | .Ar or Ap ing | |
78 | the following values: | |
79 | .Pp | |
80 | .Bl -tag -width 6n -compact -offset indent | |
81 | .It Li 4000 | |
82 | set-user-ID-on-execution | |
83 | .It Li 2000 | |
84 | set-group-ID-on-execution | |
85 | .It Li 1000 | |
86 | sticky bit, see chmod(2) | |
87 | .It Li 0400 | |
88 | read by owner | |
89 | .It Li 0200 | |
90 | write by owner | |
91 | .It Li 0100 | |
92 | execute (or search for directories) by owner | |
93 | .It Li 0070 | |
94 | read, write, execute/search by group | |
95 | .It Li 0007 | |
96 | read, write, execute/search by others | |
97 | .El | |
98 | .Pp | |
99 | The read, write, and execute/search values for group and others | |
100 | are encoded as described for owner. | |
101 | .Pp | |
102 | The symbolic mode is described by the following grammar: | |
103 | .Bd -literal -offset indent | |
104 | mode ::= clause [, clause ...] | |
105 | clause ::= [who ...] [action ...] last_action | |
106 | action ::= op [perm ...] | |
107 | last_action ::= op [perm ...] | |
108 | who ::= a | u | g | o | |
109 | op ::= + | \- | = | |
110 | perm ::= r | s | t | w | X | x | u | g | o | |
111 | .Ed | |
112 | .Pp | |
113 | The | |
114 | .Ar who | |
115 | symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts | |
116 | of the mode bits, respectively. | |
117 | The | |
118 | .Ar who | |
119 | symbol ``a'' is equivalent to ``ugo''. | |
120 | .Pp | |
121 | The | |
122 | .Ar perm | |
123 | symbols represent the portions of the mode bits as follows: | |
124 | .Pp | |
125 | .Bl -tag -width Ds -compact -offset indent | |
126 | .It r | |
127 | The read bits. | |
128 | .It s | |
129 | The set-user-ID-on-execution and set-group-ID-on-execution bits. | |
130 | .It t | |
131 | The sticky bit. | |
132 | .It w | |
133 | The write bits. | |
134 | .It x | |
135 | The execute/search bits. | |
136 | .It X | |
137 | The execute/search bits if the file is a directory or any of the | |
138 | execute/search bits are set in the original (unmodified) mode. | |
139 | Operations with the | |
140 | .Ar perm | |
141 | symbol ``X'' are only meaningful in conjunction with the | |
142 | .Ar op | |
143 | symbol ``+'', and it is ignored in all other cases. | |
144 | .El | |
145 | .Pp | |
146 | The | |
147 | .Ar op | |
148 | symbols represent the operation performed, as follows: | |
149 | .Bl -tag -width 4n | |
150 | .It + | |
151 | If no value is supplied for | |
152 | .Ar perm , | |
153 | the ``+'' operation has no effect. | |
154 | If no value is supplied for | |
155 | .Ar who , | |
156 | each permission bit specified in | |
157 | .Ar perm , | |
158 | for which the corresponding bit in the file mode creation mask | |
159 | is clear, is set. | |
160 | Otherwise, the mode bits represented by the specified | |
161 | .Ar who | |
162 | and | |
163 | .Ar perm | |
164 | values are set. | |
165 | .It \&\- | |
166 | If no value is supplied for | |
167 | .Ar perm , | |
168 | the ``\-'' operation has no effect. | |
169 | If no value is supplied for | |
170 | .Ar who , | |
171 | the mode bits represented by | |
172 | .Ar perm | |
173 | are cleared for the owner, group and other permissions. | |
174 | Otherwise, the mode bits represented by the specified | |
175 | .Ar who | |
176 | and | |
177 | .Ar perm | |
178 | values are cleared. | |
179 | .It = | |
180 | The mode bits specified by the | |
181 | .Ar who | |
182 | value are cleared, or, if no who value is specified, the owner, group | |
183 | and other mode bits are cleared. | |
184 | Then, if no value is supplied for | |
185 | .Ar who , | |
186 | each permission bit specified in | |
187 | .Ar perm , | |
188 | for which the corresponding bit in the file mode creation mask | |
189 | is clear, is set. | |
190 | Otherwise, the mode bits represented by the specified | |
191 | .Ar who | |
192 | and | |
193 | .Ar perm | |
194 | values are set. | |
195 | .El | |
196 | .Pp | |
197 | Each | |
198 | .Ar clause | |
199 | specifies one or more operations to be performed on the mode | |
200 | bits, and each operation is applied to the mode bits in the | |
201 | order specified. | |
202 | .Pp | |
203 | Operations upon the other permissions only (specified by the symbol | |
204 | ``o'' by itself), in combination with the | |
205 | .Ar perm | |
206 | symbols ``s'' or ``t'', are ignored. | |
207 | .Sh EXAMPLES | |
208 | .Bl -tag -width "u=rwx,go=u-w" -compact | |
209 | .It Li 644 | |
210 | make a file readable by anyone and writable by the owner only. | |
211 | .Pp | |
212 | .It Li go-w | |
213 | deny write permission to group and others. | |
214 | .Pp | |
215 | .It Li =rw,+X | |
216 | set the read and write permissions to the usual defaults, but | |
217 | retain any execute permissions that are currently set. | |
218 | .Pp | |
219 | .It Li +X | |
220 | make a directory or file searchable/executable by everyone if it is | |
221 | already searchable/executable by anyone. | |
222 | .Pp | |
223 | .It Li 755 | |
224 | .It Li u=rwx,go=rx | |
225 | .It Li u=rwx,go=u-w | |
226 | make a file readable/executable by everyone and writeable by the owner only. | |
227 | .Pp | |
228 | .It Li go= | |
229 | clear all mode bits for group and others. | |
230 | .Pp | |
231 | .It Li g=u-w | |
232 | set the group bits equal to the user bits, but clear the group write bit. | |
233 | .El | |
234 | .Sh BUGS | |
235 | There's no | |
236 | .Ar perm | |
237 | option for the naughty bits. | |
238 | .Sh SEE ALSO | |
239 | .Xr install 1 , | |
240 | .Xr chmod 2 , | |
241 | .Xr stat 2 , | |
242 | .Xr umask 2 , | |
243 | .Xr fts 3 , | |
244 | .Xr setmode 3 , | |
245 | .Xr chown 8 | |
246 | .Sh STANDARDS | |
247 | The | |
248 | .Nm chmod | |
249 | utility is expected to be | |
250 | .St -p1003.2 | |
251 | compatible with the exception | |
252 | of the | |
253 | .Ar perm | |
254 | symbols | |
255 | .Dq t | |
256 | and | |
257 | .Dq X | |
258 | which are not included in that standard. |