xref: /csrg-svn/bin/chmod/chmod.1 (revision 43082)
1*43082Scael.\" Copyright (c) 1989, 1990 The Regents of the University of California.
239829Sbostic.\" All rights reserved.
319384Smckusick.\"
442527Sbostic.\" %sccs.include.redist.man%
539829Sbostic.\"
6*43082Scael.\"     @(#)chmod.1	6.7 (Berkeley) 06/11/90
739829Sbostic.\"
8*43082Scael.Dd
9*43082Scael.Dt CHMOD 1
10*43082Scael.Os BSD 4.4
11*43082Scael.Sh NAME
12*43082Scael.Nm chmod
13*43082Scaelchange file modes
14*43082Scael.Sh SYNOPSIS
15*43082Scael.Nm chmod
16*43082Scael.Op Fl fR
17*43082Scael.Ar mode
18*43082Scael.Ar file ...
19*43082Scael.Sh DESCRIPTION
2039829SbosticThe
21*43082Scael.Nm chmod
2239829Sbosticutility modifies the file mode bits of the listed files
2339829Sbosticas specified by the
24*43082Scael.Ar mode
2539829Sbosticoperand.
26*43082Scael.Pp
2739829SbosticThe options are as follows:
28*43082Scael.Tp Fl f
29*43082Scael.Nm chmod
3039829Sbosticwill still exit 0 and not complain if it fails to change the mode
3139829Sbosticon a file.
32*43082Scael.Tp Fl R
3339829SbosticTraverse a file hierarchy.
3439829SbosticFor each file that is of type directory,
35*43082Scael.Nm chmod
3639829Sbosticchanges the mode of all files in the file hierarchy below it followed
3739829Sbosticby the mode of the directory itself.
38*43082Scael.Tp
39*43082Scael.Pp
4039829SbosticSymbolic links are not indirected through, nor are their modes altered.
41*43082Scael.Pp
4239829SbosticOnly the owner of a file or the super-user is permitted to change
4339829Sbosticthe mode of a file.
44*43082Scael.Pp
4539829SbosticThe
46*43082Scael.Nm chmod
4739829Sbosticutility exits 0 on success, and >0 if an error occurs.
48*43082Scael.Sh MODES
4939829SbosticModes may be absolute or symbolic.
5039829SbosticAn absolute mode is an octal number constructed by
51*43082Scael.Cx Ar or
52*43082Scael.Cx 'ing
53*43082Scael.Cx
5439829Sbosticthe following values:
55*43082Scael.Dp Li 4000
5639829Sbosticset-user-ID-on-execution
57*43082Scael.Dp Li 2000
5839829Sbosticset-group-ID-on-execution
59*43082Scael.Dp Li 1000
6039829Sbosticsticky bit, see chmod(2)
61*43082Scael.Dp Li 0400
6219384Smckusickread by owner
63*43082Scael.Dp Li 0200
6419384Smckusickwrite by owner
65*43082Scael.Dp Li 0100
6639829Sbosticexecute (or search for directories) by owner
67*43082Scael.Dp Li 0070
6839829Sbosticread, write, execute/search by group
69*43082Scael.Dp Li 0007
7039829Sbosticread, write, execute/search by others
71*43082Scael.Dp
72*43082Scael.Pp
7339829SbosticThe read, write, and execute/search values for group and others
7439829Sbosticare encoded as described for owner.
75*43082Scael.Pp
7639829SbosticThe symbolic mode is described by the following grammar:
77*43082Scael.Dp Li mode
78*43082Scael::= clause
79*43082Scael.Op  \&, clause
80*43082Scael...
81*43082Scael.Dp Li clause
82*43082Scael::=
83*43082Scael.Op  who ...
84*43082Scael.Op  action ...
85*43082Scaellast_action
86*43082Scael.Dp Li action
8741117Sbostic::= op perm ...
88*43082Scael.Dp Li last_action
89*43082Scael::= op
90*43082Scael.Op  perm ...
91*43082Scael.Dp Li who
92*43082Scael.Li ::= a | u | g | o
93*43082Scael.Dp Li op
94*43082Scael.Li ::= + |  - |  =
95*43082Scael.Dp Li perm
96*43082Scael.Li ::= r |  s |  t |  w |  X |  x
97*43082Scael.Dp
98*43082Scael.Pp
9939829SbosticThe
100*43082Scael.Ar who
10139829Sbosticsymbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
10239829Sbosticof the mode bits, respectively.
10341117SbosticThe
104*43082Scael.Ar who
10541117Sbosticsymbol ``a'' is equivalent to ``ugo''.
106*43082Scael.Pp
10739829SbosticThe
108*43082Scael.Ar perm
10939829Sbosticsymbols represent the portions of the mode bits as follows:
110*43082Scael.Dw Fl
111*43082Scael.Dp r
11239829SbosticThe read bits.
113*43082Scael.Dp s
11439829SbosticThe set-user-ID-on-execution and set-group-ID-on-execution bits.
115*43082Scael.Dp t
11641117SbosticThe sticky bit.
117*43082Scael.Dp w
11839829SbosticThe write bits.
119*43082Scael.Dp x
12041117SbosticThe execute/search bits.
121*43082Scael.Dp X
12239829SbosticThe execute/search bits if the file is a directory or any of the
12341117Sbosticexecute/search bits are set in the original (unmodified) mode.
12441117SbosticOperations with the
125*43082Scael.Ar perm
12641117Sbosticsymbol ``X'' are only meaningful in conjunction with the
127*43082Scael.Ar op
12841117Sbosticsymbol ``+'', and it is ignored in all other cases.
129*43082Scael.Dp
130*43082Scael.Pp
13139829SbosticThe
132*43082Scael.Ar op
13339829Sbosticsymbols represent the operation performed, as follows:
134*43082Scael.Tw Fl
135*43082Scael.Tp \&+
13639829SbosticIf no value is supplied for
137*43082Scael.Ar perm ,
13839829Sbosticthe ``+'' operation has no effect.
13939829SbosticIf no value is supplied for
140*43082Scael.Ar who ,
14139829Sbosticeach permission bit specified in
142*43082Scael.Ar perm ,
14341117Sbosticfor which the corresponding bit in the file mode creation mask
14441117Sbosticis clear, is set.
14541117SbosticOtherwise, the mode bits represented by the specified
146*43082Scael.Ar who
14739829Sbosticand
148*43082Scael.Ar perm
14941117Sbosticvalues are set.
150*43082Scael.Tp \&-
15139829SbosticIf no value is supplied for
152*43082Scael.Ar perm ,
15341117Sbosticthe ``-'' operation has no effect.
15441117SbosticIf no value is supplied for
155*43082Scael.Ar who ,
15641117Sbosticthe mode bits represented by
157*43082Scael.Ar perm
15841117Sbosticare cleared for the owner, group and other permissions.
15941117SbosticOtherwise, the mode bits represented by the specified
160*43082Scael.Ar who
16139829Sbosticand
162*43082Scael.Ar perm
16341117Sbosticvalues are cleared.
164*43082Scael.Tp \&=
16541117SbosticThe mode bits specified by the
166*43082Scael.Ar who
16741117Sbosticvalue are cleared, or, if no who value is specified, the owner, group
16841117Sbosticand other mode bits are cleared.
16941117SbosticThen, if no value is supplied for
170*43082Scael.Ar who ,
17141117Sbosticeach permission bit specified in
172*43082Scael.Ar perm ,
17341117Sbosticfor which the corresponding bit in the file mode creation mask
17441117Sbosticis clear, is set.
17541117SbosticOtherwise, the mode bits represented by the specified
176*43082Scael.Ar who
17739829Sbosticand
178*43082Scael.Ar perm
17941117Sbosticvalues are set.
180*43082Scael.Tp
181*43082Scael.Pp
18241117SbosticEach
183*43082Scael.Ar clause
18441117Sbosticspecifies one or more operations to be performed on the mode
18541117Sbosticbits, and each operation is applied to the mode bits in the
18641117Sbosticorder specified.
187*43082Scael.Pp
18841117SbosticOperations upon the other permissions only (specified by the symbol
18941117Sbostic``o'' by itself), in combination with the
190*43082Scael.Ar perm
19141117Sbosticsymbols ``s'' or ``t'', are ignored.
192*43082Scael.Sh EXAMPLES
193*43082Scael.Tw Fl
194*43082Scael.Tp ``644''
19541117Sbosticmake a file readable by anyone and writable by the owner only.
196*43082Scael.Tp ``go-w''
19739829Sbosticdeny write permission to group and others.
198*43082Scael.Tp ``=rw,+X''
19941117Sbosticset the read and write permissions to the usual defaults, but
20041117Sbosticretain any execute permissions that are currently set.
201*43082Scael.Tp ``+X''
20241117Sbosticmake a directory or file searchable/executable by everyone if it is
20341117Sbosticalready searchable/executable by anyone.
204*43082Scael.Tp ``755'' or ``u=rwx,go=rx''
20541117Sbosticmake a file readable/executable by everyone and writeable by the owner only.
206*43082Scael.Tp ``go=''
20739829Sbosticclear all mode bits for group and others.
208*43082Scael.Tp
209*43082Scael.Sh BUGS
21039829SbosticThere's no
211*43082Scael.Ar perm
21239829Sbosticoption for the naughty bits.
213*43082Scael.Sh ENVIRONMENT
214*43082Scael.Sh SEE ALSO
215*43082Scael.Xr install 1 ,
216*43082Scael.Xr chmod 2 ,
217*43082Scael.Xr fts 2 ,
218*43082Scael.Xr stat 2 ,
219*43082Scael.Xr umask 2 ,
220*43082Scael.Xr setmode 3 ,
221*43082Scael.Xr chown 8
222*43082Scael.Sh STANDARDS
22339829SbosticThe
224*43082Scael.Nm chmod
22539829Sbosticfunction is expected to be POSIX 1003.2 compatible with the exception
22639829Sbosticof the
227*43082Scael.Ar perm
22839829Sbosticsymbols ``t'' and ``X'' which are not included in that standard.
229