166444Sbostic.\" Copyright (c) 1989, 1990, 1993, 1994 263674Sbostic.\" The Regents of the University of California. All rights reserved. 319384Smckusick.\" 450181Sbostic.\" This code is derived from software contributed to Berkeley by 550181Sbostic.\" the Institute of Electrical and Electronics Engineers, Inc. 650181Sbostic.\" 750492Scael.\" %sccs.include.redist.roff% 839829Sbostic.\" 9*66545Sbostic.\" @(#)chmod.1 8.4 (Berkeley) 03/31/94 1039829Sbostic.\" 1143082Scael.Dd 1243082Scael.Dt CHMOD 1 1350492Scael.Os 1443082Scael.Sh NAME 1543082Scael.Nm chmod 1647089Scael.Nd change file modes 1743082Scael.Sh SYNOPSIS 1843082Scael.Nm chmod 1966543Sbostic.Oo 2066543Sbostic.Fl R 2166543Sbostic.Op Fl H | Fl L | Fl P 2266543Sbostic.Oc 2343082Scael.Ar mode 2443082Scael.Ar file ... 2543082Scael.Sh DESCRIPTION 2639829SbosticThe 2743082Scael.Nm chmod 2839829Sbosticutility modifies the file mode bits of the listed files 2939829Sbosticas specified by the 3043082Scael.Ar mode 3139829Sbosticoperand. 3243082Scael.Pp 3339829SbosticThe options are as follows: 3447089Scael.Bl -tag -width Ds 3553783Selan.It Fl H 3666543SbosticIf the 3766543Sbostic.Fl R 3866543Sbosticoption is specified, symbolic links on the command line are followed. 3966543Sbostic(Symbolic links encountered in the tree traversal are not followed.) 4066543Sbostic.It Fl L 4166543SbosticIf the 4266543Sbostic.Fl R 4366543Sbosticoption is specified, all symbolic links are followed. 4466543Sbostic.It Fl P 4566543SbosticIf the 4666543Sbostic.Fl R 4766543Sbosticoption is specified, no symbolic links are followed. 4847089Scael.It Fl R 4966543SbosticChange the modes of the file hierarchies rooted in the files 5066543Sbosticinstead of just the files themselves. 5147089Scael.El 5243082Scael.Pp 5366543SbosticSymbolic links do not have modes, so unless the 5466543Sbostic.Fl H 5553783Selanor 5666543Sbostic.Fl L 5766543Sbosticoption is set, 5853783Selan.Nm chmod 59*66545Sbosticon a symbolic link always succeeds and has no effect. 6066543SbosticThe 6166543Sbostic.Fl H , 6266543Sbostic.Fl L 6366543Sbosticand 6466543Sbostic.Fl P 6566543Sbosticoptions are ignored unless the 6666543Sbostic.Fl R 6766543Sbosticoption is specified. 6866543SbosticIn addition, these options override each other and the 6966543Sbosticcommand's actions are determined by the last one specified. 7043082Scael.Pp 7139829SbosticOnly the owner of a file or the super-user is permitted to change 7239829Sbosticthe mode of a file. 7343082Scael.Pp 7439829SbosticThe 7543082Scael.Nm chmod 7639829Sbosticutility exits 0 on success, and >0 if an error occurs. 7743082Scael.Sh MODES 7839829SbosticModes may be absolute or symbolic. 7939829SbosticAn absolute mode is an octal number constructed by 8053783Selan.Ar or-ing 8139829Sbosticthe following values: 8247089Scael.Pp 8347089Scael.Bl -tag -width 6n -compact -offset indent 8447089Scael.It Li 4000 8539829Sbosticset-user-ID-on-execution 8647089Scael.It Li 2000 8739829Sbosticset-group-ID-on-execution 8847089Scael.It Li 1000 8939829Sbosticsticky bit, see chmod(2) 9047089Scael.It Li 0400 9119384Smckusickread by owner 9247089Scael.It Li 0200 9319384Smckusickwrite by owner 9447089Scael.It Li 0100 9539829Sbosticexecute (or search for directories) by owner 9647089Scael.It Li 0070 9739829Sbosticread, write, execute/search by group 9847089Scael.It Li 0007 9939829Sbosticread, write, execute/search by others 10047089Scael.El 10143082Scael.Pp 10239829SbosticThe read, write, and execute/search values for group and others 10339829Sbosticare encoded as described for owner. 10443082Scael.Pp 10539829SbosticThe symbolic mode is described by the following grammar: 10647089Scael.Bd -literal -offset indent 10747089Scaelmode ::= clause [, clause ...] 10847089Scaelclause ::= [who ...] [action ...] last_action 10947089Scaelaction ::= op [perm ...] 11047089Scaellast_action ::= op [perm ...] 11147089Scaelwho ::= a | u | g | o 11247089Scaelop ::= + | \- | = 11366444Sbosticperm ::= r | s | t | w | x | X | u | g | o 11447089Scael.Ed 11543082Scael.Pp 11639829SbosticThe 11743082Scael.Ar who 11839829Sbosticsymbols ``u'', ``g'', and ``o'' specify the user, group, and other parts 11939829Sbosticof the mode bits, respectively. 12041117SbosticThe 12143082Scael.Ar who 12241117Sbosticsymbol ``a'' is equivalent to ``ugo''. 12343082Scael.Pp 12463673Smckusick.ne 1i 12539829SbosticThe 12643082Scael.Ar perm 12739829Sbosticsymbols represent the portions of the mode bits as follows: 12847089Scael.Pp 12947089Scael.Bl -tag -width Ds -compact -offset indent 13047089Scael.It r 13139829SbosticThe read bits. 13247089Scael.It s 13339829SbosticThe set-user-ID-on-execution and set-group-ID-on-execution bits. 13447089Scael.It t 13541117SbosticThe sticky bit. 13647089Scael.It w 13739829SbosticThe write bits. 13847089Scael.It x 13941117SbosticThe execute/search bits. 14047089Scael.It X 14139829SbosticThe execute/search bits if the file is a directory or any of the 14241117Sbosticexecute/search bits are set in the original (unmodified) mode. 14341117SbosticOperations with the 14443082Scael.Ar perm 14541117Sbosticsymbol ``X'' are only meaningful in conjunction with the 14643082Scael.Ar op 14763673Smckusicksymbol ``+'', and are ignored in all other cases. 14866444Sbostic.It u 14966444SbosticThe user permission bits in the mode of the original file. 15066444Sbostic.It g 15166444SbosticThe group permission bits in the mode of the original file. 15266444Sbostic.It o 15366444SbosticThe other permission bits in the mode of the original file. 15447089Scael.El 15543082Scael.Pp 15639829SbosticThe 15743082Scael.Ar op 15839829Sbosticsymbols represent the operation performed, as follows: 15947089Scael.Bl -tag -width 4n 16047089Scael.It + 16139829SbosticIf no value is supplied for 16243082Scael.Ar perm , 16339829Sbosticthe ``+'' operation has no effect. 16439829SbosticIf no value is supplied for 16543082Scael.Ar who , 16639829Sbosticeach permission bit specified in 16743082Scael.Ar perm , 16841117Sbosticfor which the corresponding bit in the file mode creation mask 16941117Sbosticis clear, is set. 17041117SbosticOtherwise, the mode bits represented by the specified 17143082Scael.Ar who 17239829Sbosticand 17343082Scael.Ar perm 17441117Sbosticvalues are set. 17547089Scael.It \&\- 17639829SbosticIf no value is supplied for 17743082Scael.Ar perm , 17847089Scaelthe ``\-'' operation has no effect. 17941117SbosticIf no value is supplied for 18043082Scael.Ar who , 18166444Sbosticeach permission bit specified in 18266444Sbostic.Ar perm , 18366444Sbosticfor which the corresponding bit in the file mode creation mask 18466444Sbosticis clear, is cleared. 18541117SbosticOtherwise, the mode bits represented by the specified 18643082Scael.Ar who 18739829Sbosticand 18843082Scael.Ar perm 18941117Sbosticvalues are cleared. 19047089Scael.It = 19141117SbosticThe mode bits specified by the 19243082Scael.Ar who 19341117Sbosticvalue are cleared, or, if no who value is specified, the owner, group 19441117Sbosticand other mode bits are cleared. 19541117SbosticThen, if no value is supplied for 19643082Scael.Ar who , 19741117Sbosticeach permission bit specified in 19843082Scael.Ar perm , 19941117Sbosticfor which the corresponding bit in the file mode creation mask 20041117Sbosticis clear, is set. 20141117SbosticOtherwise, the mode bits represented by the specified 20243082Scael.Ar who 20339829Sbosticand 20443082Scael.Ar perm 20541117Sbosticvalues are set. 20647089Scael.El 20743082Scael.Pp 20841117SbosticEach 20943082Scael.Ar clause 21041117Sbosticspecifies one or more operations to be performed on the mode 21141117Sbosticbits, and each operation is applied to the mode bits in the 21241117Sbosticorder specified. 21343082Scael.Pp 21441117SbosticOperations upon the other permissions only (specified by the symbol 21541117Sbostic``o'' by itself), in combination with the 21643082Scael.Ar perm 21741117Sbosticsymbols ``s'' or ``t'', are ignored. 21843082Scael.Sh EXAMPLES 21947089Scael.Bl -tag -width "u=rwx,go=u-w" -compact 22047089Scael.It Li 644 22141117Sbosticmake a file readable by anyone and writable by the owner only. 22247089Scael.Pp 22347089Scael.It Li go-w 22439829Sbosticdeny write permission to group and others. 22547089Scael.Pp 22647089Scael.It Li =rw,+X 22741117Sbosticset the read and write permissions to the usual defaults, but 22841117Sbosticretain any execute permissions that are currently set. 22947089Scael.Pp 23047089Scael.It Li +X 23141117Sbosticmake a directory or file searchable/executable by everyone if it is 23241117Sbosticalready searchable/executable by anyone. 23347089Scael.Pp 23447089Scael.It Li 755 23547089Scael.It Li u=rwx,go=rx 23647089Scael.It Li u=rwx,go=u-w 23766543Sbosticmake a file readable/executable by everyone and writable by the owner only. 23847089Scael.Pp 23947089Scael.It Li go= 24039829Sbosticclear all mode bits for group and others. 24147089Scael.Pp 24247089Scael.It Li g=u-w 24345902Sbosticset the group bits equal to the user bits, but clear the group write bit. 24447089Scael.El 24543082Scael.Sh BUGS 24639829SbosticThere's no 24743082Scael.Ar perm 24839829Sbosticoption for the naughty bits. 24943082Scael.Sh SEE ALSO 25043082Scael.Xr install 1 , 25143082Scael.Xr chmod 2 , 25243082Scael.Xr stat 2 , 25343082Scael.Xr umask 2 , 25445903Sbostic.Xr fts 3 , 25543082Scael.Xr setmode 3 , 25655736Sbostic.Xr symlink 7 , 25743082Scael.Xr chown 8 25843082Scael.Sh STANDARDS 25939829SbosticThe 26043082Scael.Nm chmod 26163673Smckusickutility is expected to be POSIX 1003.2 26263673Smckusickcompatible with the exception of the 26343082Scael.Ar perm 26447089Scaelsymbols 26547089Scael.Dq t 26647089Scaeland 26747089Scael.Dq X 26847089Scaelwhich are not included in that standard. 269