xref: /csrg-svn/bin/chmod/chmod.1 (revision 39829)
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.4 (Berkeley) 01/01/90

CHMOD 1 ""
C 7
NAME
chmod - change file modes
SYNOPSIS
chmod [-fR] mode file ...
DESCRIPTION
The chmod utility modifies the file mode bits of the listed files as specified by the mode operand.

The options are as follows:

-f If the -f option is given, chmod will still exit 0 and not complain if it fails to change the mode on a file.

-R Traverse a file hierarchy. For each file that is of type directory, chmod changes the mode of all files in the file hierarchy below it followed by the mode of the directory itself.

Symbolic links are not indirected through, nor are their modes altered.

Only the owner of a file or the super-user is permitted to change the mode of a file.

The chmod utility exits 0 on success, and >0 if an error occurs.

MODES
Modes may be absolute or symbolic. An absolute mode is an octal number constructed by or 'ing the following values:

8 4000 set-user-ID-on-execution

.ns

2000 set-group-ID-on-execution

.ns

1000 sticky bit, see chmod(2)

.ns

0400 read by owner

.ns

0200 write by owner

.ns

0100 execute (or search for directories) by owner

.ns

0070 read, write, execute/search by group

.ns

0007 read, write, execute/search by others

The read, write, and execute/search values for group and others are encoded as described for owner.

The symbolic mode is described by the following grammar:

newmode ::= clause [ , clause ] clause ::= [ who ] op [ perm ] who ::= [ u | g | o ] ... | a op ::= + | - | = perm ::= [ r | s | t | w | X | x ] ...

Each clause specifies an operation to be performed on the current mode bits. Each operation is applied to the mode bits in the order specified.

The who symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts of the mode bits, respectively. A who consisting of the symbol ``a'' is equivalent to ``ugo''.

The perm symbols represent the portions of the mode bits as follows:

r The read bits.

s The set-user-ID-on-execution and set-group-ID-on-execution bits.

t The sticky bits.

w The write bits.

X The execute/search bits if the file is a directory or any of the execute/search bits are already set.

x The execute/search bits.

The op symbols represent the operation performed, as follows:

+ If no value is supplied for perm , the ``+'' operation has no effect. If no value is supplied for who , each permission bit specified in perm , for which the corresponding bit in the file mode creation mask of the invoking process is clear, is set, and, if perm includes ``s'', the set-user-ID-on-execution and set-group-ID-on-execution bits are set. If values are provided for both who and perm , each mode bit represented by the specified who and perm values is set.

- If no value is supplied for who , clear the mode bits represented by perm for the owner, group, and other permissions. Otherwise, clear the mode bits represented by the specified who and perm values.

= If no value is supplied for who , set the permission bits specified in perm that correspond to bits that are not set in the value of the file mode creation mask of the invoking process. Otherwise, clear all the mode bits for user, group, and other as specified by the who value. Then, if a value is supplied for both perm and who , set each mode bit represented by all combinations of the specified who and perm values.

Operations upon the other permissions (specified by the symbol ``o'' or the symbol ``a'') in combination with the perm symbols ``s'' or ``t'' are ignored, and do not change any mode bits or cause an error.

EXAMPLES

``644'' make a file readable by anyone but writeable only by the owner.

.ns

``go-w'' deny write permission to group and others.

.ns

``+X'' make a file executable by everyone if it is already executable by anyone.

.ns

``711'' or ``u=rwx,go=x'' make a file executable by everyone and read/writeable by the owner only.

``go='' clear all mode bits for group and others.

BUGS
There's no perm option for the naughty bits.
ENVIRONMENT
"SEE ALSO"
install(1), chmod(2), fts(2), stat(2), umask(2), setmode(3), chown(8)
STANDARDS
The chmod function is expected to be POSIX 1003.2 compatible with the exception of the perm symbols ``t'' and ``X'' which are not included in that standard.