chmod(1) CLIX chmod(1)
NAME
chmod - Changes mode of files and directories
SYNOPSIS
chmod mode file ...
chmod mode directory ...
DESCRIPTION
The permissions of the named files or directory are changed according to
mode, which may be symbolic or absolute. Absolute changes to permissions
are stated using octal numbers as follows:
chmod nnnn file ...
The n argument is a number from 0 to 7. Symbolic changes are stated using
mnemonic characters as follows:
chmod xyz, ... file ...
The x argument is one or more characters corresponding to user, group, or
other; y is +, -, or =, signifying permission assignment; and z is one or
more characters corresponding to permission type.
If a named file is a symbolic link, the permissions of the referenced file
(or directory) are changed, and the permissions of the symbolic link are
undisturbed.
An absolute mode is given as an octal number constructed from the OR of
the following modes:
4000 Set-user-ID on execution.
20#0 Set-group-ID on execution if # is 7, 5, 3, or 1; enable mandatory
locking if # is 6, 4, 2, or 0.
1000 Sticky bit is turned on ((see chmod(2)).
0400 Read by owner.
0200 Write by owner.
0100 Execute (search in directory) by owner.
0040 Read by group.
0020 Write by group.
2/94 - Intergraph Corporation 1
chmod(1) CLIX chmod(1)
0010 Execute (search) by group.
0004 Read by others.
0002 Write by others.
0001 Execute (search) by others.
Symbolic changes are stated using letters that correspond both to access
classes and to the individual permissions. Permissions to a file may vary
depending on the user identification number (UID) or group identification
number (GID). Permissions are described in three sequences, each having
three characters:
User Group Other
rwx rwx rwx
This example (meaning that user, group, and others all have read, write,
and execute permissions for a given file) demonstrates two categories for
granting permissions: the access class and the permissions themselves.
Thus, to change the mode of a file's (or directory's) permissions using
the chmod symbolic method, use the following syntax for mode:
[who]operator[permission(s)], ...
A command line using the symbolic method would appear as follows:
chmod g+rw file
This command would allow group to read and write file.
Who can be stated as one or more of the following letters:
u User's permissions.
g Group's permissions.
o Other's permissions.
a Equivalent to ugo (all) and is the default if who is omitted.
Operator can be + to add permission to the file's mode, - to take away
permission, or = to assign permission absolutely. (Unlike other symbolic
operations, = has an absolute effect in that it resets all other bits.)
Omitting permission is only useful with = to remove all permissions.
Permission is any compatible combination of the following letters:
r Read permission.
2 Intergraph Corporation - 2/94
chmod(1) CLIX chmod(1)
w Write permission.
x Execute permission.
s Set-user-ID or set-group-ID is turned on.
t Sticky bit is turned on.
l Mandatory locking will occur during access.
Multiple symbolic modes separated by commas may be given, although these
modes cannot have spaces between them. Operations are performed in the
order given. Multiple symbolic letters following a single operator cause
the corresponding operations to be performed simultaneously. The letter s
is only meaningful with u or g, and t only works with u.
Mandatory file and record locking (l) refers to a file's ability to have
its read or write 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-ID and enable a file to be locked on execution at
the same time. Therefore, the following examples are illegal uses and
will elicit error messages:
chmod g+x,+l file
chmod g+s,+l file
Only the owner of a file or directory (or the superuser) may change a
file's mode. Only the superuser may set the sticky bit. Before the
file's set-group-ID can be turned on, the user's group ID must correspond
to the file's and group execution must be set.
EXAMPLES
The following commands deny execution permission to all users. The
absolute (octal) example permits only reading permissions.
chmod a-x file
chmod 444 file
The following commands enable the group and others to read and write a
file:
chmod go=rw file
chmod 066 file
This command causes a file to be locked during access:
chmod +l file
These examples enable all to read, write, and execute the file. They also
2/94 - Intergraph Corporation 3
chmod(1) CLIX chmod(1)
turn on the set-group-ID.
chmod =rwx,g+s file
chmod 2777 file
NOTES
In a Remote File Sharing environment, a user may not have the permissions
that the output of the ls -l command implies.
RELATED INFORMATION
Commands: ls(1)
Functions: chmod(2)
AT&T UNIX System V System Administrator's Guide.
4 Intergraph Corporation - 2/94