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