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