'\"macro stdmacro
.if n .pH g1.chmod @(#)chmod	41.1 of 12/20/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} chmod 1 "Essential Utilities" "\&"
.if \nX=1 .ds x} chmod 1 "Essential Utilities"
.if \nX=2 .ds x} chmod 1 "" "\&"
.if \nX=3 .ds x} chmod "" "" "\&"
.TH \*(x}
.\" @(#)chmod.1 1.3 88/08/25 SMI; 
.SH NAME
\f4chmod\f1 \- change file mode
.SH SYNOPSIS
\f4chmod\fP
[
\f4\-R\fP
]
\f2mode file\fP ...
.br
\f4chmod \f1[\f4ugoa\f1 ]{\|\f4+\f1 |\|\f4-\f1 |\|\f4=\f1\|}[ \f4rwxlstugo\f1 ] \f2file\f1 ...
.SH DESCRIPTION
\f4chmod\fP changes or assigns the mode of a file.
The mode of a file specifies its permissions and other attributes.
The mode may be absolute or symbolic.
.P
An absolute
.I mode
is specified using octal numbers:
.P
.RS
\f4chmod\f1 \f2nnnn file\f1 ...
.RE
.P
where \f2n\f1 is a number from 0 to 7.
An absolute mode is constructed
from the \s-1OR\s+1 of any of the following modes:
.PP
.PD 0
.RS
.TP 10
4000
Set user
.SM ID on execution.
.TP 10
20\f2#\f10
Set group
.SM ID
on execution if \f2#\f1 is \f47\f1, \f45\f1, \f43\f1, or \f41\f1.
.IP
Enable mandatory locking if \f2#\f1 is \f46\f1, \f44\f1, \f42\f1, or \f40\f1.
.IP
This bit is ignored if the file is a directory;
it may be set or cleared only using the symbolic mode.
.TP 10
1000
Turn on sticky bit [\^(see \f4chmod\fP(2)\^].
.TP 10
0400
Allow read by owner.
.TP 10
0200
Allow write by owner.
.TP 10
0100
Allow execute (search in directory) by owner.
.TP 10
0070
Allow read, write, and execute (search) by group.
.TP 10
0007
Allow read, write, and execute (search) by others.
.RE
.PD
.P
A symbolic \f2mode\fP is specified in
the following format:
.P
.RS
\f4chmod \f1[ \f2who\f1 ]  \f2operator\f1  [ \f2permission(s) \f1]  \f2 file\f1 ...
.RE
.P
.I who
is zero or more of the characters
\f4u\fP, \f4g\fP, \f4o\fP, and \f4a\fP specifying whose permissions
are to be changed or assigned:
.P
.RS
.PD 0
.TP 10
\f4u\f1
user's permissions
.TP 10
\f4g\f1
group's permissions
.TP 10
\f4o\f1
others' permissions
.TP 10
\f4a\f1
all permissions (user, group, and other)
.PD
.RE
.PP
If
.I who\^
is omitted, it defaults to \f4a\fP.
.P
.I operator
is one of \f4\(pl\f1, \f4\(mi\f1, or \f4\(eq\f1,
signifying how permissions are to be changed:
.P
.RS
.PD 0
.TP 10
\f4+\fP
Add permissions.
.TP 10
\f4\-\fP
Take away permissions.
.TP 10
\f4=\fP
Assign permissions absolutely.
.PD
.RE
.P
Unlike other symbolic operations, \f4=\f1 has an absolute effect in that it
resets all other bits.
Omitting \f2permission\f1(s)
is useful only with
\f4=\f1
to take away
all permissions.
.P
\f2permission\f1(s)
is any compatible combination of the following letters:
.P
.RS
.PD 0
.TP 10
\f4r\f1
read permission
.TP 10
\f4w\f1
write permission
.TP 10
\f4x\f1
execute permission
.TP 10
\f4s\f1
user or group set-\s-1ID\s+1
.TP 10
\f4t\f1
sticky bit
.TP 10
\f4l\f1
mandatory locking
.TP 10
\f4u, g, o\fP
indicate that \f2permission\f1 is to be taken from
the current user, group or other mode respectively.
.PD
.RE
.PP
Permissions to a file may vary depending on your user identification
number (\s-1UID\s0) or group identification number (\s-1GID\s0).
Permissions are described in three sequences each having
three characters:
.P
.TS
center ;
c c c
cf4 cf4 cf4 .
User	Group	Other
.sp 0.5
rwx	rwx	rwx
.TE
.P
This example (user, group, and others
all have permission to read, write, and execute
a given file) demonstrates two categories for granting permissions:
the access class and the permissions themselves.
.PP
Multiple symbolic modes separated by commas may be given, though
no spaces may intervene between these modes.
Operations are performed in the order given.
Multiple symbolic letters following a single operator cause the 
corresponding operations to be performed simultaneously.
.P
The letter
\f4s\f1
is only meaningful
with
\f4u\f1
or
\f4g\f1,
and
\f4t\f1
only works
with
\f4u\f1.
.PP
Mandatory file and record locking (\^\f4l\^\f1) refers to a file's
ability to have its reading or writing permissions locked
while a program is accessing that file.
It is not possible to
permit group execution and enable a file to be locked on
execution at the same time.
In addition, it is not possible to turn on the set-group-\s-1ID\s+1 bit
and enable a file to be locked on execution at the same time.
The following examples, therefore, are invalid and
elicit error messages:
.P
.RS
.nf
\f4chmod g+x,+l\f1 \f2file\f1
\f4chmod g+s,+l\f1 \f2file\f1
.fi
.RE
.PP
Only the owner of a file or directory (or the super-user) may change that
file's or directory's mode.
Only the super-user may set the sticky bit on a non-directory file.
If you are not super-user, \f4chmod\f1 will mask
the sticky-bit but will not return an error.
In order to turn on a file's set-group-\s-1ID\s+1 bit,
your own group \s-1ID\s+1 must
correspond to the file's and group execution must be set.
.P
The
\f4\-R\f1
option recursively descends through directory arguments, setting
the mode for each file as described above.
.SH EXAMPLES
Deny execute permission to everyone:
.P
.RS
\f4chmod a\-x\f1 \f2file\f1
.RE
.P
Allow read permission to everyone:
.P
.RS
\f4chmod 444\f1 \f2file\f1
.RE
.PP
Make a file readable and writable by the group and others:
.P
.RS
.nf
\f4chmod go+rw\f1 \f2file\f1
\f4chmod 066\f1 \f2file\f1
.fi
.RE
.PP
Cause a file to be locked during access:
.P
.RS
\f4chmod +l\f1 \f2file\f1
.RE
.PP
Allow everyone to read, write, and execute the file
and turn on the set group-ID.
.P
.RS
.nf
\f4chmod =rwx,g+s\f1 \f2file\f1
\f4chmod 2777\f1 \f2file\f1
.fi
.RE
.PP
Absolute changes don't work for the set-group-\s-1ID\s0 bit of a directory.
You must use \f4g+s\f1 or \f4g-s\f1.
.SH "SEE ALSO"
\f4ls\fP(1).
.br
\f4chmod\fP(2) in the \f2Programmer's Reference Manual\f1
.SH "NOTES"
\f4chmod\fP permits you to produce useless 
modes so long as they are not illegal (e.g.,
making a text file executable).
\f4chmod\fP does not check the file type to see if mandatory locking
is available.
