.\" Copyright (c) 1989 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)chmod.1 6.5 (Berkeley) 04/28/90 .\" .TH CHMOD 1 "" .UC 7 .SH NAME chmod - change file modes .SH SYNOPSIS .nf chmod [-fR] mode file ... .fi .SH DESCRIPTION The .I chmod utility modifies the file mode bits of the listed files as specified by the .I mode operand. .PP The options are as follows: .TP -f If the -f option is given, .I chmod will still exit 0 and not complain if it fails to change the mode on a file. .TP -R Traverse a file hierarchy. For each file that is of type directory, .I chmod changes the mode of all files in the file hierarchy below it followed by the mode of the directory itself. .PP Symbolic links are not indirected through, nor are their modes altered. .PP Only the owner of a file or the super-user is permitted to change the mode of a file. .PP The .I chmod utility exits 0 on success, and >0 if an error occurs. .SH MODES Modes may be absolute or symbolic. An absolute mode is an octal number constructed by .IR or 'ing the following values: .RS .TP 10 4000 set-user-ID-on-execution .br .ns .TP 2000 set-group-ID-on-execution .br .ns .TP 1000 sticky bit, see chmod(2) .br .ns .TP 0400 read by owner .br .ns .TP 0200 write by owner .br .ns .TP 0100 execute (or search for directories) by owner .br .ns .TP 0070 read, write, execute/search by group .br .ns .TP 0007 read, write, execute/search by others .RE .PP The read, write, and execute/search values for group and others are encoded as described for owner. .PP The symbolic mode is described by the following grammar: .RS .TP 10 mode ::= clause [ , clause ] ... .br .ns .TP clause ::= [ who ... ] [ action ... ] last_action .br .ns .TP action ::= op perm ... .br .ns .TP last_action ::= op [ perm ... ] .br .ns .TP who ::= a | u | g | o .br .ns .TP op ::= + | - | = .br .ns .TP perm ::= r | s | t | w | X | x .RE .PP The .I who symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts of the mode bits, respectively. The .I who symbol ``a'' is equivalent to ``ugo''. .PP The .I perm symbols represent the portions of the mode bits as follows: .RS .TP 10 r The read bits. .br .ns .TP s The set-user-ID-on-execution and set-group-ID-on-execution bits. .br .ns .TP t The sticky bit. .br .ns .TP w The write bits. .br .ns .TP x The execute/search bits. .br .ns .TP X The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. Operations with the .I perm symbol ``X'' are only meaningful in conjunction with the .I op symbol ``+'', and it is ignored in all other cases. .RE .PP The .I op symbols represent the operation performed, as follows: .TP + If no value is supplied for .IR perm , the ``+'' operation has no effect. If no value is supplied for .IR who , each permission bit specified in .IR perm , for which the corresponding bit in the file mode creation mask is clear, is set. Otherwise, the mode bits represented by the specified .I who and .I perm values are set. .TP - If no value is supplied for .IR perm , the ``-'' operation has no effect. If no value is supplied for .IR who , the mode bits represented by .I perm are cleared for the owner, group and other permissions. Otherwise, the mode bits represented by the specified .I who and .I perm values are cleared. .TP = The mode bits specified by the .I who value are cleared, or, if no who value is specified, the owner, group and other mode bits are cleared. Then, if no value is supplied for .IR who , each permission bit specified in .IR perm , for which the corresponding bit in the file mode creation mask is clear, is set. Otherwise, the mode bits represented by the specified .I who and .I perm values are set. .PP Each .I clause specifies one or more operations to be performed on the mode bits, and each operation is applied to the mode bits in the order specified. .PP Operations upon the other permissions only (specified by the symbol ``o'' by itself), in combination with the .I perm symbols ``s'' or ``t'', are ignored. .SH EXAMPLES .TP ``644'' make a file readable by anyone and writable by the owner only. .TP ``go-w'' deny write permission to group and others. .TP ``=rw,+X'' set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set. .TP ``+X'' make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone. .TP ``755'' or ``u=rwx,go=rx'' make a file readable/executable by everyone and writeable by the owner only. .TP ``go='' clear all mode bits for group and others. .SH BUGS There's no .I perm option for the naughty bits. .SH ENVIRONMENT .SH "SEE ALSO" install(1), chmod(2), fts(2), stat(2), umask(2), setmode(3), chown(8) .SH STANDARDS The .I chmod function is expected to be POSIX 1003.2 compatible with the exception of the .I perm symbols ``t'' and ``X'' which are not included in that standard.