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