Commit | Line | Data |
---|---|---|
6aa2c2f8 KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
27c71911 | 4 | .\" %sccs.include.redist.man% |
6aa2c2f8 | 5 | .\" |
27c71911 | 6 | .\" @(#)chmod.1 6.6 (Berkeley) %G% |
aed64a6e | 7 | .\" |
87a10ef1 | 8 | .TH CHMOD 1 "" |
6aa2c2f8 | 9 | .UC 7 |
aed64a6e | 10 | .SH NAME |
6aa2c2f8 | 11 | chmod - change file modes |
aed64a6e | 12 | .SH SYNOPSIS |
6aa2c2f8 KB |
13 | .nf |
14 | chmod [-fR] mode file ... | |
15 | .fi | |
aed64a6e | 16 | .SH DESCRIPTION |
6aa2c2f8 KB |
17 | The |
18 | .I chmod | |
19 | utility modifies the file mode bits of the listed files | |
20 | as specified by the | |
21 | .I mode | |
22 | operand. | |
23 | .PP | |
24 | The options are as follows: | |
25 | .TP | |
26 | -f | |
27 | If the -f option is given, | |
28 | .I chmod | |
29 | will still exit 0 and not complain if it fails to change the mode | |
30 | on a file. | |
31 | .TP | |
32 | -R | |
33 | Traverse a file hierarchy. | |
34 | For each file that is of type directory, | |
35 | .I chmod | |
36 | changes the mode of all files in the file hierarchy below it followed | |
37 | by the mode of the directory itself. | |
38 | .PP | |
39 | Symbolic links are not indirected through, nor are their modes altered. | |
40 | .PP | |
41 | Only the owner of a file or the super-user is permitted to change | |
42 | the mode of a file. | |
43 | .PP | |
44 | The | |
45 | .I chmod | |
46 | utility exits 0 on success, and >0 if an error occurs. | |
47 | .SH MODES | |
48 | Modes may be absolute or symbolic. | |
49 | An absolute mode is an octal number constructed by | |
50 | .IR or 'ing | |
51 | the following values: | |
52 | .RS | |
d7ba284c | 53 | .TP 10 |
aed64a6e | 54 | 4000 |
6aa2c2f8 | 55 | set-user-ID-on-execution |
aed64a6e | 56 | .br |
aed64a6e | 57 | .ns |
6aa2c2f8 | 58 | .TP |
aed64a6e | 59 | 2000 |
6aa2c2f8 | 60 | set-group-ID-on-execution |
aed64a6e | 61 | .br |
aed64a6e | 62 | .ns |
6aa2c2f8 | 63 | .TP |
aed64a6e | 64 | 1000 |
6aa2c2f8 | 65 | sticky bit, see chmod(2) |
aed64a6e | 66 | .br |
aed64a6e | 67 | .ns |
6aa2c2f8 | 68 | .TP |
aed64a6e KM |
69 | 0400 |
70 | read by owner | |
71 | .br | |
aed64a6e | 72 | .ns |
6aa2c2f8 | 73 | .TP |
aed64a6e KM |
74 | 0200 |
75 | write by owner | |
76 | .br | |
aed64a6e | 77 | .ns |
6aa2c2f8 | 78 | .TP |
aed64a6e | 79 | 0100 |
6aa2c2f8 | 80 | execute (or search for directories) by owner |
aed64a6e | 81 | .br |
aed64a6e | 82 | .ns |
6aa2c2f8 | 83 | .TP |
aed64a6e | 84 | 0070 |
6aa2c2f8 | 85 | read, write, execute/search by group |
aed64a6e | 86 | .br |
aed64a6e | 87 | .ns |
6aa2c2f8 | 88 | .TP |
aed64a6e | 89 | 0007 |
6aa2c2f8 | 90 | read, write, execute/search by others |
d7ba284c | 91 | .RE |
87a10ef1 | 92 | .PP |
6aa2c2f8 KB |
93 | The read, write, and execute/search values for group and others |
94 | are encoded as described for owner. | |
16b7e896 | 95 | .PP |
6aa2c2f8 | 96 | The symbolic mode is described by the following grammar: |
6aa2c2f8 | 97 | .RS |
d7ba284c KB |
98 | .TP 10 |
99 | mode | |
100 | ::= clause [ , clause ] ... | |
101 | .br | |
102 | .ns | |
103 | .TP | |
104 | clause | |
105 | ::= [ who ... ] [ action ... ] last_action | |
106 | .br | |
107 | .ns | |
108 | .TP | |
109 | action | |
110 | ::= op perm ... | |
111 | .br | |
112 | .ns | |
113 | .TP | |
114 | last_action | |
115 | ::= op [ perm ... ] | |
116 | .br | |
117 | .ns | |
118 | .TP | |
119 | who | |
120 | ::= a | u | g | o | |
121 | .br | |
122 | .ns | |
123 | .TP | |
124 | op | |
125 | ::= + | - | = | |
126 | .br | |
127 | .ns | |
128 | .TP | |
129 | perm | |
130 | ::= r | s | t | w | X | x | |
6aa2c2f8 | 131 | .RE |
6aa2c2f8 KB |
132 | .PP |
133 | The | |
134 | .I who | |
135 | symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts | |
136 | of the mode bits, respectively. | |
d7ba284c | 137 | The |
6aa2c2f8 | 138 | .I who |
d7ba284c | 139 | symbol ``a'' is equivalent to ``ugo''. |
6aa2c2f8 KB |
140 | .PP |
141 | The | |
142 | .I perm | |
143 | symbols represent the portions of the mode bits as follows: | |
d7ba284c KB |
144 | .RS |
145 | .TP 10 | |
6aa2c2f8 KB |
146 | r |
147 | The read bits. | |
d7ba284c KB |
148 | .br |
149 | .ns | |
6aa2c2f8 KB |
150 | .TP |
151 | s | |
152 | The set-user-ID-on-execution and set-group-ID-on-execution bits. | |
d7ba284c KB |
153 | .br |
154 | .ns | |
6aa2c2f8 KB |
155 | .TP |
156 | t | |
d7ba284c KB |
157 | The sticky bit. |
158 | .br | |
159 | .ns | |
6aa2c2f8 KB |
160 | .TP |
161 | w | |
162 | The write bits. | |
d7ba284c KB |
163 | .br |
164 | .ns | |
6aa2c2f8 KB |
165 | .TP |
166 | x | |
167 | The execute/search bits. | |
d7ba284c KB |
168 | .br |
169 | .ns | |
170 | .TP | |
171 | X | |
172 | The execute/search bits if the file is a directory or any of the | |
173 | execute/search bits are set in the original (unmodified) mode. | |
174 | Operations with the | |
175 | .I perm | |
176 | symbol ``X'' are only meaningful in conjunction with the | |
177 | .I op | |
178 | symbol ``+'', and it is ignored in all other cases. | |
179 | .RE | |
6aa2c2f8 KB |
180 | .PP |
181 | The | |
182 | .I op | |
183 | symbols represent the operation performed, as follows: | |
184 | .TP | |
185 | + | |
186 | If no value is supplied for | |
187 | .IR perm , | |
188 | the ``+'' operation has no effect. | |
189 | If no value is supplied for | |
190 | .IR who , | |
191 | each permission bit specified in | |
192 | .IR perm , | |
d7ba284c KB |
193 | for which the corresponding bit in the file mode creation mask |
194 | is clear, is set. | |
195 | Otherwise, the mode bits represented by the specified | |
6aa2c2f8 KB |
196 | .I who |
197 | and | |
198 | .I perm | |
d7ba284c | 199 | values are set. |
6aa2c2f8 KB |
200 | .TP |
201 | - | |
202 | If no value is supplied for | |
d7ba284c KB |
203 | .IR perm , |
204 | the ``-'' operation has no effect. | |
205 | If no value is supplied for | |
6aa2c2f8 | 206 | .IR who , |
d7ba284c | 207 | the mode bits represented by |
6aa2c2f8 | 208 | .I perm |
d7ba284c KB |
209 | are cleared for the owner, group and other permissions. |
210 | Otherwise, the mode bits represented by the specified | |
6aa2c2f8 KB |
211 | .I who |
212 | and | |
213 | .I perm | |
d7ba284c | 214 | values are cleared. |
6aa2c2f8 KB |
215 | .TP |
216 | = | |
d7ba284c | 217 | The mode bits specified by the |
6aa2c2f8 | 218 | .I who |
d7ba284c KB |
219 | value are cleared, or, if no who value is specified, the owner, group |
220 | and other mode bits are cleared. | |
221 | Then, if no value is supplied for | |
6aa2c2f8 | 222 | .IR who , |
d7ba284c KB |
223 | each permission bit specified in |
224 | .IR perm , | |
225 | for which the corresponding bit in the file mode creation mask | |
226 | is clear, is set. | |
227 | Otherwise, the mode bits represented by the specified | |
6aa2c2f8 KB |
228 | .I who |
229 | and | |
230 | .I perm | |
d7ba284c | 231 | values are set. |
6aa2c2f8 | 232 | .PP |
d7ba284c KB |
233 | Each |
234 | .I clause | |
235 | specifies one or more operations to be performed on the mode | |
236 | bits, and each operation is applied to the mode bits in the | |
237 | order specified. | |
238 | .PP | |
239 | Operations upon the other permissions only (specified by the symbol | |
240 | ``o'' by itself), in combination with the | |
6aa2c2f8 | 241 | .I perm |
d7ba284c | 242 | symbols ``s'' or ``t'', are ignored. |
9dfaf149 | 243 | .SH EXAMPLES |
6aa2c2f8 KB |
244 | .TP |
245 | ``644'' | |
d7ba284c | 246 | make a file readable by anyone and writable by the owner only. |
6aa2c2f8 KB |
247 | .TP |
248 | ``go-w'' | |
249 | deny write permission to group and others. | |
d7ba284c KB |
250 | .TP |
251 | ``=rw,+X'' | |
252 | set the read and write permissions to the usual defaults, but | |
253 | retain any execute permissions that are currently set. | |
6aa2c2f8 KB |
254 | .TP |
255 | ``+X'' | |
d7ba284c KB |
256 | make a directory or file searchable/executable by everyone if it is |
257 | already searchable/executable by anyone. | |
6aa2c2f8 | 258 | .TP |
d7ba284c KB |
259 | ``755'' or ``u=rwx,go=rx'' |
260 | make a file readable/executable by everyone and writeable by the owner only. | |
6aa2c2f8 KB |
261 | .TP |
262 | ``go='' | |
263 | clear all mode bits for group and others. | |
264 | .SH BUGS | |
265 | There's no | |
266 | .I perm | |
267 | option for the naughty bits. | |
268 | .SH ENVIRONMENT | |
aed64a6e | 269 | .SH "SEE ALSO" |
6aa2c2f8 KB |
270 | install(1), chmod(2), fts(2), stat(2), umask(2), setmode(3), chown(8) |
271 | .SH STANDARDS | |
272 | The | |
273 | .I chmod | |
274 | function is expected to be POSIX 1003.2 compatible with the exception | |
275 | of the | |
276 | .I perm | |
277 | symbols ``t'' and ``X'' which are not included in that standard. |