Commit | Line | Data |
---|---|---|
5f9c6326 | 1 | .\" Copyright (c) 1989, 1990, 1993, 1994 |
22c0a769 | 2 | .\" The Regents of the University of California. All rights reserved. |
6aa2c2f8 | 3 | .\" |
cf136d2c KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
dc1d5c6f | 7 | .\" %sccs.include.redist.roff% |
6aa2c2f8 | 8 | .\" |
17beb503 | 9 | .\" @(#)chmod.1 8.3 (Berkeley) %G% |
aed64a6e | 10 | .\" |
b5dc1377 CL |
11 | .Dd |
12 | .Dt CHMOD 1 | |
dc1d5c6f | 13 | .Os |
b5dc1377 CL |
14 | .Sh NAME |
15 | .Nm chmod | |
7bcabb1e | 16 | .Nd change file modes |
b5dc1377 CL |
17 | .Sh SYNOPSIS |
18 | .Nm chmod | |
17beb503 KB |
19 | .Oo |
20 | .Fl R | |
21 | .Op Fl H | Fl L | Fl P | |
22 | .Oc | |
b5dc1377 CL |
23 | .Ar mode |
24 | .Ar file ... | |
25 | .Sh DESCRIPTION | |
6aa2c2f8 | 26 | The |
b5dc1377 | 27 | .Nm chmod |
6aa2c2f8 KB |
28 | utility modifies the file mode bits of the listed files |
29 | as specified by the | |
b5dc1377 | 30 | .Ar mode |
6aa2c2f8 | 31 | operand. |
b5dc1377 | 32 | .Pp |
6aa2c2f8 | 33 | The options are as follows: |
7bcabb1e | 34 | .Bl -tag -width Ds |
bf0d6e3a | 35 | .It Fl H |
17beb503 KB |
36 | If the |
37 | .Fl R | |
38 | option is specified, symbolic links on the command line are followed. | |
39 | (Symbolic links encountered in the tree traversal are not followed.) | |
40 | .It Fl L | |
41 | If the | |
42 | .Fl R | |
43 | option is specified, all symbolic links are followed. | |
44 | .It Fl P | |
45 | If the | |
46 | .Fl R | |
47 | option is specified, no symbolic links are followed. | |
7bcabb1e | 48 | .It Fl R |
17beb503 KB |
49 | Change the modes of the file hierarchies rooted in the files |
50 | instead of just the files themselves. | |
7bcabb1e | 51 | .El |
b5dc1377 | 52 | .Pp |
17beb503 | 53 | Symbolic links do not have modes, so unless the |
bf0d6e3a | 54 | .Fl H |
17beb503 KB |
55 | or |
56 | .Fl L | |
57 | option is set, | |
bf0d6e3a EA |
58 | .Nm chmod |
59 | on a symbolic link is a no-op. | |
17beb503 KB |
60 | The |
61 | .Fl H , | |
62 | .Fl L | |
63 | and | |
64 | .Fl P | |
65 | options are ignored unless the | |
66 | .Fl R | |
67 | option is specified. | |
68 | In addition, these options override each other and the | |
69 | command's actions are determined by the last one specified. | |
b5dc1377 | 70 | .Pp |
6aa2c2f8 KB |
71 | Only the owner of a file or the super-user is permitted to change |
72 | the mode of a file. | |
b5dc1377 | 73 | .Pp |
6aa2c2f8 | 74 | The |
b5dc1377 | 75 | .Nm chmod |
6aa2c2f8 | 76 | utility exits 0 on success, and >0 if an error occurs. |
b5dc1377 | 77 | .Sh MODES |
6aa2c2f8 KB |
78 | Modes may be absolute or symbolic. |
79 | An absolute mode is an octal number constructed by | |
bf0d6e3a | 80 | .Ar or-ing |
6aa2c2f8 | 81 | the following values: |
7bcabb1e CL |
82 | .Pp |
83 | .Bl -tag -width 6n -compact -offset indent | |
84 | .It Li 4000 | |
6aa2c2f8 | 85 | set-user-ID-on-execution |
7bcabb1e | 86 | .It Li 2000 |
6aa2c2f8 | 87 | set-group-ID-on-execution |
7bcabb1e | 88 | .It Li 1000 |
6aa2c2f8 | 89 | sticky bit, see chmod(2) |
7bcabb1e | 90 | .It Li 0400 |
aed64a6e | 91 | read by owner |
7bcabb1e | 92 | .It Li 0200 |
aed64a6e | 93 | write by owner |
7bcabb1e | 94 | .It Li 0100 |
6aa2c2f8 | 95 | execute (or search for directories) by owner |
7bcabb1e | 96 | .It Li 0070 |
6aa2c2f8 | 97 | read, write, execute/search by group |
7bcabb1e | 98 | .It Li 0007 |
6aa2c2f8 | 99 | read, write, execute/search by others |
7bcabb1e | 100 | .El |
b5dc1377 | 101 | .Pp |
6aa2c2f8 KB |
102 | The read, write, and execute/search values for group and others |
103 | are encoded as described for owner. | |
b5dc1377 | 104 | .Pp |
6aa2c2f8 | 105 | The symbolic mode is described by the following grammar: |
7bcabb1e CL |
106 | .Bd -literal -offset indent |
107 | mode ::= clause [, clause ...] | |
108 | clause ::= [who ...] [action ...] last_action | |
109 | action ::= op [perm ...] | |
110 | last_action ::= op [perm ...] | |
111 | who ::= a | u | g | o | |
112 | op ::= + | \- | = | |
5f9c6326 | 113 | perm ::= r | s | t | w | x | X | u | g | o |
7bcabb1e | 114 | .Ed |
b5dc1377 | 115 | .Pp |
6aa2c2f8 | 116 | The |
b5dc1377 | 117 | .Ar who |
6aa2c2f8 KB |
118 | symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts |
119 | of the mode bits, respectively. | |
d7ba284c | 120 | The |
b5dc1377 | 121 | .Ar who |
d7ba284c | 122 | symbol ``a'' is equivalent to ``ugo''. |
b5dc1377 | 123 | .Pp |
87d618d9 | 124 | .ne 1i |
6aa2c2f8 | 125 | The |
b5dc1377 | 126 | .Ar perm |
6aa2c2f8 | 127 | symbols represent the portions of the mode bits as follows: |
7bcabb1e CL |
128 | .Pp |
129 | .Bl -tag -width Ds -compact -offset indent | |
130 | .It r | |
6aa2c2f8 | 131 | The read bits. |
7bcabb1e | 132 | .It s |
6aa2c2f8 | 133 | The set-user-ID-on-execution and set-group-ID-on-execution bits. |
7bcabb1e | 134 | .It t |
d7ba284c | 135 | The sticky bit. |
7bcabb1e | 136 | .It w |
6aa2c2f8 | 137 | The write bits. |
7bcabb1e | 138 | .It x |
6aa2c2f8 | 139 | The execute/search bits. |
7bcabb1e | 140 | .It X |
d7ba284c KB |
141 | The execute/search bits if the file is a directory or any of the |
142 | execute/search bits are set in the original (unmodified) mode. | |
143 | Operations with the | |
b5dc1377 | 144 | .Ar perm |
d7ba284c | 145 | symbol ``X'' are only meaningful in conjunction with the |
b5dc1377 | 146 | .Ar op |
87d618d9 | 147 | symbol ``+'', and are ignored in all other cases. |
5f9c6326 KB |
148 | .It u |
149 | The user permission bits in the mode of the original file. | |
150 | .It g | |
151 | The group permission bits in the mode of the original file. | |
152 | .It o | |
153 | The other permission bits in the mode of the original file. | |
7bcabb1e | 154 | .El |
b5dc1377 | 155 | .Pp |
6aa2c2f8 | 156 | The |
b5dc1377 | 157 | .Ar op |
6aa2c2f8 | 158 | symbols represent the operation performed, as follows: |
7bcabb1e CL |
159 | .Bl -tag -width 4n |
160 | .It + | |
6aa2c2f8 | 161 | If no value is supplied for |
b5dc1377 | 162 | .Ar perm , |
6aa2c2f8 KB |
163 | the ``+'' operation has no effect. |
164 | If no value is supplied for | |
b5dc1377 | 165 | .Ar who , |
6aa2c2f8 | 166 | each permission bit specified in |
b5dc1377 | 167 | .Ar perm , |
d7ba284c KB |
168 | for which the corresponding bit in the file mode creation mask |
169 | is clear, is set. | |
170 | Otherwise, the mode bits represented by the specified | |
b5dc1377 | 171 | .Ar who |
6aa2c2f8 | 172 | and |
b5dc1377 | 173 | .Ar perm |
d7ba284c | 174 | values are set. |
7bcabb1e | 175 | .It \&\- |
6aa2c2f8 | 176 | If no value is supplied for |
b5dc1377 | 177 | .Ar perm , |
7bcabb1e | 178 | the ``\-'' operation has no effect. |
d7ba284c | 179 | If no value is supplied for |
b5dc1377 | 180 | .Ar who , |
5f9c6326 KB |
181 | each permission bit specified in |
182 | .Ar perm , | |
183 | for which the corresponding bit in the file mode creation mask | |
184 | is clear, is cleared. | |
d7ba284c | 185 | Otherwise, the mode bits represented by the specified |
b5dc1377 | 186 | .Ar who |
6aa2c2f8 | 187 | and |
b5dc1377 | 188 | .Ar perm |
d7ba284c | 189 | values are cleared. |
7bcabb1e | 190 | .It = |
d7ba284c | 191 | The mode bits specified by the |
b5dc1377 | 192 | .Ar who |
d7ba284c KB |
193 | value are cleared, or, if no who value is specified, the owner, group |
194 | and other mode bits are cleared. | |
195 | Then, if no value is supplied for | |
b5dc1377 | 196 | .Ar who , |
d7ba284c | 197 | each permission bit specified in |
b5dc1377 | 198 | .Ar perm , |
d7ba284c KB |
199 | for which the corresponding bit in the file mode creation mask |
200 | is clear, is set. | |
201 | Otherwise, the mode bits represented by the specified | |
b5dc1377 | 202 | .Ar who |
6aa2c2f8 | 203 | and |
b5dc1377 | 204 | .Ar perm |
d7ba284c | 205 | values are set. |
7bcabb1e | 206 | .El |
b5dc1377 | 207 | .Pp |
d7ba284c | 208 | Each |
b5dc1377 | 209 | .Ar clause |
d7ba284c KB |
210 | specifies one or more operations to be performed on the mode |
211 | bits, and each operation is applied to the mode bits in the | |
212 | order specified. | |
b5dc1377 | 213 | .Pp |
d7ba284c KB |
214 | Operations upon the other permissions only (specified by the symbol |
215 | ``o'' by itself), in combination with the | |
b5dc1377 | 216 | .Ar perm |
d7ba284c | 217 | symbols ``s'' or ``t'', are ignored. |
b5dc1377 | 218 | .Sh EXAMPLES |
7bcabb1e CL |
219 | .Bl -tag -width "u=rwx,go=u-w" -compact |
220 | .It Li 644 | |
d7ba284c | 221 | make a file readable by anyone and writable by the owner only. |
7bcabb1e CL |
222 | .Pp |
223 | .It Li go-w | |
6aa2c2f8 | 224 | deny write permission to group and others. |
7bcabb1e CL |
225 | .Pp |
226 | .It Li =rw,+X | |
d7ba284c KB |
227 | set the read and write permissions to the usual defaults, but |
228 | retain any execute permissions that are currently set. | |
7bcabb1e CL |
229 | .Pp |
230 | .It Li +X | |
d7ba284c KB |
231 | make a directory or file searchable/executable by everyone if it is |
232 | already searchable/executable by anyone. | |
7bcabb1e CL |
233 | .Pp |
234 | .It Li 755 | |
235 | .It Li u=rwx,go=rx | |
236 | .It Li u=rwx,go=u-w | |
17beb503 | 237 | make a file readable/executable by everyone and writable by the owner only. |
7bcabb1e CL |
238 | .Pp |
239 | .It Li go= | |
6aa2c2f8 | 240 | clear all mode bits for group and others. |
7bcabb1e CL |
241 | .Pp |
242 | .It Li g=u-w | |
89b2cc72 | 243 | set the group bits equal to the user bits, but clear the group write bit. |
7bcabb1e | 244 | .El |
b5dc1377 | 245 | .Sh BUGS |
6aa2c2f8 | 246 | There's no |
b5dc1377 | 247 | .Ar perm |
6aa2c2f8 | 248 | option for the naughty bits. |
b5dc1377 CL |
249 | .Sh SEE ALSO |
250 | .Xr install 1 , | |
251 | .Xr chmod 2 , | |
b5dc1377 CL |
252 | .Xr stat 2 , |
253 | .Xr umask 2 , | |
7f58c379 | 254 | .Xr fts 3 , |
b5dc1377 | 255 | .Xr setmode 3 , |
0d17b9a2 | 256 | .Xr symlink 7 , |
b5dc1377 CL |
257 | .Xr chown 8 |
258 | .Sh STANDARDS | |
6aa2c2f8 | 259 | The |
b5dc1377 | 260 | .Nm chmod |
87d618d9 KM |
261 | utility is expected to be POSIX 1003.2 |
262 | compatible with the exception of the | |
b5dc1377 | 263 | .Ar perm |
7bcabb1e CL |
264 | symbols |
265 | .Dq t | |
266 | and | |
267 | .Dq X | |
268 | which are not included in that standard. |