Deleted Added
full compact
chmod.1 (22988) chmod.1 (31144)
1.\" Copyright (c) 1989, 1990, 1993, 1994
2.\" The Regents of the University of California. 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 8.4 (Berkeley) 3/31/94
1.\" Copyright (c) 1989, 1990, 1993, 1994
2.\" The Regents of the University of California. 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 8.4 (Berkeley) 3/31/94
36.\" $Id$
36.\" $Id: chmod.1,v 1.7 1997/02/22 14:01:29 peter Exp $
37.\"
38.Dd March 31, 1994
39.Dt CHMOD 1
40.Os
41.Sh NAME
42.Nm chmod
43.Nd change file modes
44.Sh SYNOPSIS
45.Nm chmod
46.Oo
47.Fl R
48.Op Fl H | Fl L | Fl P
49.Oc
50.Ar mode
51.Ar file ...
52.Sh DESCRIPTION
53The
54.Nm chmod
55utility modifies the file mode bits of the listed files
56as specified by the
57.Ar mode
58operand.
59.Pp
60The options are as follows:
61.Bl -tag -width Ds
62.It Fl H
63If the
64.Fl R
65option is specified, symbolic links on the command line are followed.
66(Symbolic links encountered in the tree traversal are not followed.)
67.It Fl L
68If the
69.Fl R
70option is specified, all symbolic links are followed.
71.It Fl P
72If the
73.Fl R
74option is specified, no symbolic links are followed.
75.It Fl R
76Change the modes of the file hierarchies rooted in the files
77instead of just the files themselves.
78.El
79.Pp
80Symbolic links do not have modes, so unless the
81.Fl H
82or
83.Fl L
84option is set,
85.Nm chmod
86on a symbolic link always succeeds and has no effect.
87The
88.Fl H ,
89.Fl L
90and
91.Fl P
92options are ignored unless the
93.Fl R
94option is specified.
95In addition, these options override each other and the
96command's actions are determined by the last one specified.
97.Pp
98Only the owner of a file or the super-user is permitted to change
99the mode of a file.
100.Pp
101The
102.Nm chmod
103utility exits 0 on success, and >0 if an error occurs.
104.Sh MODES
105Modes may be absolute or symbolic.
106An absolute mode is an octal number constructed by
107.Ar or-ing
108the following values:
109.Pp
110.Bl -tag -width 6n -compact -offset indent
111.It Li 4000
112set-user-ID-on-execution
37.\"
38.Dd March 31, 1994
39.Dt CHMOD 1
40.Os
41.Sh NAME
42.Nm chmod
43.Nd change file modes
44.Sh SYNOPSIS
45.Nm chmod
46.Oo
47.Fl R
48.Op Fl H | Fl L | Fl P
49.Oc
50.Ar mode
51.Ar file ...
52.Sh DESCRIPTION
53The
54.Nm chmod
55utility modifies the file mode bits of the listed files
56as specified by the
57.Ar mode
58operand.
59.Pp
60The options are as follows:
61.Bl -tag -width Ds
62.It Fl H
63If the
64.Fl R
65option is specified, symbolic links on the command line are followed.
66(Symbolic links encountered in the tree traversal are not followed.)
67.It Fl L
68If the
69.Fl R
70option is specified, all symbolic links are followed.
71.It Fl P
72If the
73.Fl R
74option is specified, no symbolic links are followed.
75.It Fl R
76Change the modes of the file hierarchies rooted in the files
77instead of just the files themselves.
78.El
79.Pp
80Symbolic links do not have modes, so unless the
81.Fl H
82or
83.Fl L
84option is set,
85.Nm chmod
86on a symbolic link always succeeds and has no effect.
87The
88.Fl H ,
89.Fl L
90and
91.Fl P
92options are ignored unless the
93.Fl R
94option is specified.
95In addition, these options override each other and the
96command's actions are determined by the last one specified.
97.Pp
98Only the owner of a file or the super-user is permitted to change
99the mode of a file.
100.Pp
101The
102.Nm chmod
103utility exits 0 on success, and >0 if an error occurs.
104.Sh MODES
105Modes may be absolute or symbolic.
106An absolute mode is an octal number constructed by
107.Ar or-ing
108the following values:
109.Pp
110.Bl -tag -width 6n -compact -offset indent
111.It Li 4000
112set-user-ID-on-execution
113( see
114.Xr chmod 2
115for directories )
113.It Li 2000
114set-group-ID-on-execution
115.It Li 1000
116.It Li 2000
117set-group-ID-on-execution
118.It Li 1000
116sticky bit, see chmod(2)
119sticky bit, see
120.Xr chmod 2
117.It Li 0400
118read by owner
119.It Li 0200
120write by owner
121.It Li 0100
122execute (or search for directories) by owner
123.It Li 0070
124read, write, execute/search by group
125.It Li 0007
126read, write, execute/search by others
127.El
128.Pp
129The read, write, and execute/search values for group and others
130are encoded as described for owner.
131.Pp
132The symbolic mode is described by the following grammar:
133.Bd -literal -offset indent
134mode ::= clause [, clause ...]
135clause ::= [who ...] [action ...] last_action
136action ::= op [perm ...]
137last_action ::= op [perm ...]
138who ::= a | u | g | o
139op ::= + | \- | =
140perm ::= r | s | t | w | x | X | u | g | o
141.Ed
142.Pp
143The
144.Ar who
145symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
146of the mode bits, respectively.
147The
148.Ar who
149symbol ``a'' is equivalent to ``ugo''.
150.Pp
151.ne 1i
152The
153.Ar perm
154symbols represent the portions of the mode bits as follows:
155.Pp
156.Bl -tag -width Ds -compact -offset indent
157.It r
158The read bits.
159.It s
160The set-user-ID-on-execution and set-group-ID-on-execution bits.
161.It t
162The sticky bit.
163.It w
164The write bits.
165.It x
166The execute/search bits.
167.It X
168The execute/search bits if the file is a directory or any of the
169execute/search bits are set in the original (unmodified) mode.
170Operations with the
171.Ar perm
172symbol ``X'' are only meaningful in conjunction with the
173.Ar op
174symbol ``+'', and are ignored in all other cases.
175.It u
176The user permission bits in the mode of the original file.
177.It g
178The group permission bits in the mode of the original file.
179.It o
180The other permission bits in the mode of the original file.
181.El
182.Pp
183The
184.Ar op
185symbols represent the operation performed, as follows:
186.Bl -tag -width 4n
187.It +
188If no value is supplied for
189.Ar perm ,
190the ``+'' operation has no effect.
191If no value is supplied for
192.Ar who ,
193each permission bit specified in
194.Ar perm ,
195for which the corresponding bit in the file mode creation mask
196is clear, is set.
197Otherwise, the mode bits represented by the specified
198.Ar who
199and
200.Ar perm
201values are set.
202.It \&\-
203If no value is supplied for
204.Ar perm ,
205the ``\-'' operation has no effect.
206If no value is supplied for
207.Ar who ,
208each permission bit specified in
209.Ar perm ,
210for which the corresponding bit in the file mode creation mask
211is clear, is cleared.
212Otherwise, the mode bits represented by the specified
213.Ar who
214and
215.Ar perm
216values are cleared.
217.It =
218The mode bits specified by the
219.Ar who
220value are cleared, or, if no who value is specified, the owner, group
221and other mode bits are cleared.
222Then, if no value is supplied for
223.Ar who ,
224each permission bit specified in
225.Ar perm ,
226for which the corresponding bit in the file mode creation mask
227is clear, is set.
228Otherwise, the mode bits represented by the specified
229.Ar who
230and
231.Ar perm
232values are set.
233.El
234.Pp
235Each
236.Ar clause
237specifies one or more operations to be performed on the mode
238bits, and each operation is applied to the mode bits in the
239order specified.
240.Pp
241Operations upon the other permissions only (specified by the symbol
242``o'' by itself), in combination with the
243.Ar perm
244symbols ``s'' or ``t'', are ignored.
245.Sh EXAMPLES
246.Bl -tag -width "u=rwx,go=u-w" -compact
247.It Li 644
248make a file readable by anyone and writable by the owner only.
249.Pp
250.It Li go-w
251deny write permission to group and others.
252.Pp
253.It Li =rw,+X
254set the read and write permissions to the usual defaults, but
255retain any execute permissions that are currently set.
256.Pp
257.It Li +X
258make a directory or file searchable/executable by everyone if it is
259already searchable/executable by anyone.
260.Pp
261.It Li 755
262.It Li u=rwx,go=rx
263.It Li u=rwx,go=u-w
264make a file readable/executable by everyone and writable by the owner only.
265.Pp
266.It Li go=
267clear all mode bits for group and others.
268.Pp
269.It Li g=u-w
270set the group bits equal to the user bits, but clear the group write bit.
271.El
272.Sh BUGS
273There's no
274.Ar perm
275option for the naughty bits.
276.Sh SEE ALSO
277.Xr chflags 1 ,
278.Xr install 1 ,
279.Xr chmod 2 ,
280.Xr stat 2 ,
281.Xr umask 2 ,
282.Xr fts 3 ,
283.Xr setmode 3 ,
284.Xr symlink 7 ,
285.Xr chown 8
286.Sh STANDARDS
287The
288.Nm chmod
289utility is expected to be
290.St -p1003.2
291compatible with the exception of the
292.Ar perm
293symbols
294.Dq t
295and
296.Dq X
297which are not included in that standard.
298.Sh HISTORY
299A
300.Nm
301command appeared in
302.At v1 .
121.It Li 0400
122read by owner
123.It Li 0200
124write by owner
125.It Li 0100
126execute (or search for directories) by owner
127.It Li 0070
128read, write, execute/search by group
129.It Li 0007
130read, write, execute/search by others
131.El
132.Pp
133The read, write, and execute/search values for group and others
134are encoded as described for owner.
135.Pp
136The symbolic mode is described by the following grammar:
137.Bd -literal -offset indent
138mode ::= clause [, clause ...]
139clause ::= [who ...] [action ...] last_action
140action ::= op [perm ...]
141last_action ::= op [perm ...]
142who ::= a | u | g | o
143op ::= + | \- | =
144perm ::= r | s | t | w | x | X | u | g | o
145.Ed
146.Pp
147The
148.Ar who
149symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
150of the mode bits, respectively.
151The
152.Ar who
153symbol ``a'' is equivalent to ``ugo''.
154.Pp
155.ne 1i
156The
157.Ar perm
158symbols represent the portions of the mode bits as follows:
159.Pp
160.Bl -tag -width Ds -compact -offset indent
161.It r
162The read bits.
163.It s
164The set-user-ID-on-execution and set-group-ID-on-execution bits.
165.It t
166The sticky bit.
167.It w
168The write bits.
169.It x
170The execute/search bits.
171.It X
172The execute/search bits if the file is a directory or any of the
173execute/search bits are set in the original (unmodified) mode.
174Operations with the
175.Ar perm
176symbol ``X'' are only meaningful in conjunction with the
177.Ar op
178symbol ``+'', and are ignored in all other cases.
179.It u
180The user permission bits in the mode of the original file.
181.It g
182The group permission bits in the mode of the original file.
183.It o
184The other permission bits in the mode of the original file.
185.El
186.Pp
187The
188.Ar op
189symbols represent the operation performed, as follows:
190.Bl -tag -width 4n
191.It +
192If no value is supplied for
193.Ar perm ,
194the ``+'' operation has no effect.
195If no value is supplied for
196.Ar who ,
197each permission bit specified in
198.Ar perm ,
199for which the corresponding bit in the file mode creation mask
200is clear, is set.
201Otherwise, the mode bits represented by the specified
202.Ar who
203and
204.Ar perm
205values are set.
206.It \&\-
207If no value is supplied for
208.Ar perm ,
209the ``\-'' operation has no effect.
210If no value is supplied for
211.Ar who ,
212each permission bit specified in
213.Ar perm ,
214for which the corresponding bit in the file mode creation mask
215is clear, is cleared.
216Otherwise, the mode bits represented by the specified
217.Ar who
218and
219.Ar perm
220values are cleared.
221.It =
222The mode bits specified by the
223.Ar who
224value are cleared, or, if no who value is specified, the owner, group
225and other mode bits are cleared.
226Then, if no value is supplied for
227.Ar who ,
228each permission bit specified in
229.Ar perm ,
230for which the corresponding bit in the file mode creation mask
231is clear, is set.
232Otherwise, the mode bits represented by the specified
233.Ar who
234and
235.Ar perm
236values are set.
237.El
238.Pp
239Each
240.Ar clause
241specifies one or more operations to be performed on the mode
242bits, and each operation is applied to the mode bits in the
243order specified.
244.Pp
245Operations upon the other permissions only (specified by the symbol
246``o'' by itself), in combination with the
247.Ar perm
248symbols ``s'' or ``t'', are ignored.
249.Sh EXAMPLES
250.Bl -tag -width "u=rwx,go=u-w" -compact
251.It Li 644
252make a file readable by anyone and writable by the owner only.
253.Pp
254.It Li go-w
255deny write permission to group and others.
256.Pp
257.It Li =rw,+X
258set the read and write permissions to the usual defaults, but
259retain any execute permissions that are currently set.
260.Pp
261.It Li +X
262make a directory or file searchable/executable by everyone if it is
263already searchable/executable by anyone.
264.Pp
265.It Li 755
266.It Li u=rwx,go=rx
267.It Li u=rwx,go=u-w
268make a file readable/executable by everyone and writable by the owner only.
269.Pp
270.It Li go=
271clear all mode bits for group and others.
272.Pp
273.It Li g=u-w
274set the group bits equal to the user bits, but clear the group write bit.
275.El
276.Sh BUGS
277There's no
278.Ar perm
279option for the naughty bits.
280.Sh SEE ALSO
281.Xr chflags 1 ,
282.Xr install 1 ,
283.Xr chmod 2 ,
284.Xr stat 2 ,
285.Xr umask 2 ,
286.Xr fts 3 ,
287.Xr setmode 3 ,
288.Xr symlink 7 ,
289.Xr chown 8
290.Sh STANDARDS
291The
292.Nm chmod
293utility is expected to be
294.St -p1003.2
295compatible with the exception of the
296.Ar perm
297symbols
298.Dq t
299and
300.Dq X
301which are not included in that standard.
302.Sh HISTORY
303A
304.Nm
305command appeared in
306.At v1 .