143082Scael.\" Copyright (c) 1989, 1990 The Regents of the University of California. 239829Sbostic.\" All rights reserved. 319384Smckusick.\" 442527Sbostic.\" %sccs.include.redist.man% 539829Sbostic.\" 6*47089Scael.\" @(#)chmod.1 6.13 (Berkeley) 03/07/91 739829Sbostic.\" 843082Scael.Dd 943082Scael.Dt CHMOD 1 1043082Scael.Os BSD 4.4 1143082Scael.Sh NAME 1243082Scael.Nm chmod 13*47089Scael.Nd change file modes 1443082Scael.Sh SYNOPSIS 1543082Scael.Nm chmod 16*47089Scael.Op Fl R 1743082Scael.Ar mode 1843082Scael.Ar file ... 1943082Scael.Sh DESCRIPTION 2039829SbosticThe 2143082Scael.Nm chmod 2239829Sbosticutility modifies the file mode bits of the listed files 2339829Sbosticas specified by the 2443082Scael.Ar mode 2539829Sbosticoperand. 2643082Scael.Pp 2739829SbosticThe options are as follows: 28*47089Scael.Bl -tag -width Ds 29*47089Scael.It Fl R 3039829SbosticTraverse a file hierarchy. 3139829SbosticFor each file that is of type directory, 3243082Scael.Nm chmod 3339829Sbosticchanges the mode of all files in the file hierarchy below it followed 3439829Sbosticby the mode of the directory itself. 35*47089Scael.El 3643082Scael.Pp 3739829SbosticSymbolic links are not indirected through, nor are their modes altered. 3843082Scael.Pp 3939829SbosticOnly the owner of a file or the super-user is permitted to change 4039829Sbosticthe mode of a file. 4143082Scael.Pp 4239829SbosticThe 4343082Scael.Nm chmod 4439829Sbosticutility exits 0 on success, and >0 if an error occurs. 4543082Scael.Sh MODES 4639829SbosticModes may be absolute or symbolic. 4739829SbosticAn absolute mode is an octal number constructed by 48*47089Scael.Ar or Ap ing 4939829Sbosticthe following values: 50*47089Scael.Pp 51*47089Scael.Bl -tag -width 6n -compact -offset indent 52*47089Scael.It Li 4000 5339829Sbosticset-user-ID-on-execution 54*47089Scael.It Li 2000 5539829Sbosticset-group-ID-on-execution 56*47089Scael.It Li 1000 5739829Sbosticsticky bit, see chmod(2) 58*47089Scael.It Li 0400 5919384Smckusickread by owner 60*47089Scael.It Li 0200 6119384Smckusickwrite by owner 62*47089Scael.It Li 0100 6339829Sbosticexecute (or search for directories) by owner 64*47089Scael.It Li 0070 6539829Sbosticread, write, execute/search by group 66*47089Scael.It Li 0007 6739829Sbosticread, write, execute/search by others 68*47089Scael.El 6943082Scael.Pp 7039829SbosticThe read, write, and execute/search values for group and others 7139829Sbosticare encoded as described for owner. 7243082Scael.Pp 7339829SbosticThe symbolic mode is described by the following grammar: 74*47089Scael.Bd -literal -offset indent 75*47089Scaelmode ::= clause [, clause ...] 76*47089Scaelclause ::= [who ...] [action ...] last_action 77*47089Scaelaction ::= op [perm ...] 78*47089Scaellast_action ::= op [perm ...] 79*47089Scaelwho ::= a | u | g | o 80*47089Scaelop ::= + | \- | = 81*47089Scaelperm ::= r | s | t | w | X | x | u | g | o 82*47089Scael.Ed 8343082Scael.Pp 8439829SbosticThe 8543082Scael.Ar who 8639829Sbosticsymbols ``u'', ``g'', and ``o'' specify the user, group, and other parts 8739829Sbosticof the mode bits, respectively. 8841117SbosticThe 8943082Scael.Ar who 9041117Sbosticsymbol ``a'' is equivalent to ``ugo''. 9143082Scael.Pp 9239829SbosticThe 9343082Scael.Ar perm 9439829Sbosticsymbols represent the portions of the mode bits as follows: 95*47089Scael.Pp 96*47089Scael.Bl -tag -width Ds -compact -offset indent 97*47089Scael.It r 9839829SbosticThe read bits. 99*47089Scael.It s 10039829SbosticThe set-user-ID-on-execution and set-group-ID-on-execution bits. 101*47089Scael.It t 10241117SbosticThe sticky bit. 103*47089Scael.It w 10439829SbosticThe write bits. 105*47089Scael.It x 10641117SbosticThe execute/search bits. 107*47089Scael.It X 10839829SbosticThe execute/search bits if the file is a directory or any of the 10941117Sbosticexecute/search bits are set in the original (unmodified) mode. 11041117SbosticOperations with the 11143082Scael.Ar perm 11241117Sbosticsymbol ``X'' are only meaningful in conjunction with the 11343082Scael.Ar op 11441117Sbosticsymbol ``+'', and it is ignored in all other cases. 115*47089Scael.El 11643082Scael.Pp 11739829SbosticThe 11843082Scael.Ar op 11939829Sbosticsymbols represent the operation performed, as follows: 120*47089Scael.Bl -tag -width 4n 121*47089Scael.It + 12239829SbosticIf no value is supplied for 12343082Scael.Ar perm , 12439829Sbosticthe ``+'' operation has no effect. 12539829SbosticIf no value is supplied for 12643082Scael.Ar who , 12739829Sbosticeach permission bit specified in 12843082Scael.Ar perm , 12941117Sbosticfor which the corresponding bit in the file mode creation mask 13041117Sbosticis clear, is set. 13141117SbosticOtherwise, the mode bits represented by the specified 13243082Scael.Ar who 13339829Sbosticand 13443082Scael.Ar perm 13541117Sbosticvalues are set. 136*47089Scael.It \&\- 13739829SbosticIf no value is supplied for 13843082Scael.Ar perm , 139*47089Scaelthe ``\-'' operation has no effect. 14041117SbosticIf no value is supplied for 14143082Scael.Ar who , 14241117Sbosticthe mode bits represented by 14343082Scael.Ar perm 14441117Sbosticare cleared for the owner, group and other permissions. 14541117SbosticOtherwise, the mode bits represented by the specified 14643082Scael.Ar who 14739829Sbosticand 14843082Scael.Ar perm 14941117Sbosticvalues are cleared. 150*47089Scael.It = 15141117SbosticThe mode bits specified by the 15243082Scael.Ar who 15341117Sbosticvalue are cleared, or, if no who value is specified, the owner, group 15441117Sbosticand other mode bits are cleared. 15541117SbosticThen, if no value is supplied for 15643082Scael.Ar who , 15741117Sbosticeach permission bit specified in 15843082Scael.Ar perm , 15941117Sbosticfor which the corresponding bit in the file mode creation mask 16041117Sbosticis clear, is set. 16141117SbosticOtherwise, the mode bits represented by the specified 16243082Scael.Ar who 16339829Sbosticand 16443082Scael.Ar perm 16541117Sbosticvalues are set. 166*47089Scael.El 16743082Scael.Pp 16841117SbosticEach 16943082Scael.Ar clause 17041117Sbosticspecifies one or more operations to be performed on the mode 17141117Sbosticbits, and each operation is applied to the mode bits in the 17241117Sbosticorder specified. 17343082Scael.Pp 17441117SbosticOperations upon the other permissions only (specified by the symbol 17541117Sbostic``o'' by itself), in combination with the 17643082Scael.Ar perm 17741117Sbosticsymbols ``s'' or ``t'', are ignored. 17843082Scael.Sh EXAMPLES 179*47089Scael.Bl -tag -width "u=rwx,go=u-w" -compact 180*47089Scael.It Li 644 18141117Sbosticmake a file readable by anyone and writable by the owner only. 182*47089Scael.Pp 183*47089Scael.It Li go-w 18439829Sbosticdeny write permission to group and others. 185*47089Scael.Pp 186*47089Scael.It Li =rw,+X 18741117Sbosticset the read and write permissions to the usual defaults, but 18841117Sbosticretain any execute permissions that are currently set. 189*47089Scael.Pp 190*47089Scael.It Li +X 19141117Sbosticmake a directory or file searchable/executable by everyone if it is 19241117Sbosticalready searchable/executable by anyone. 193*47089Scael.Pp 194*47089Scael.It Li 755 195*47089Scael.It Li u=rwx,go=rx 196*47089Scael.It Li u=rwx,go=u-w 19741117Sbosticmake a file readable/executable by everyone and writeable by the owner only. 198*47089Scael.Pp 199*47089Scael.It Li go= 20039829Sbosticclear all mode bits for group and others. 201*47089Scael.Pp 202*47089Scael.It Li g=u-w 20345902Sbosticset the group bits equal to the user bits, but clear the group write bit. 204*47089Scael.El 20543082Scael.Sh BUGS 20639829SbosticThere's no 20743082Scael.Ar perm 20839829Sbosticoption for the naughty bits. 20943082Scael.Sh SEE ALSO 21043082Scael.Xr install 1 , 21143082Scael.Xr chmod 2 , 21243082Scael.Xr stat 2 , 21343082Scael.Xr umask 2 , 21445903Sbostic.Xr fts 3 , 21543082Scael.Xr setmode 3 , 21643082Scael.Xr chown 8 21743082Scael.Sh STANDARDS 21839829SbosticThe 21943082Scael.Nm chmod 22044952Scaelutility is expected to be POSIX 1003.2 compatible with the exception 22139829Sbosticof the 22243082Scael.Ar perm 223*47089Scaelsymbols 224*47089Scael.Dq t 225*47089Scaeland 226*47089Scael.Dq X 227*47089Scaelwhich are not included in that standard. 228