CHMOD(1) — Kubota Pacfic Computer Inc. (Essential Utilities)
NAME
chmod − change mode
SYNOPSIS
chmod mode file ...
chmod mode directory ...
DESCRIPTION
The permissions of the named files or directories are changed according to mode, which may be symbolic or absolute. Absolute changes to permissions are stated using octal numbers:
chmod nnn file(s)
where n is a number from 0 to 7. Symbolic changes are stated using mnemonic characters:
chmod a operator b file(s)
where a is one or more characters corresponding to user, group, or other; where operator is +, −, and =, signifying assignment of permissions; and where b is one or more characters corresponding to type of permission.
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
0070 read, write, execute (search) by group
0007 read, write, execute (search) by others
Symbolic changes are stated using letters that correspond both to access classes and to the individual permissions themselves. Permissions to a file may vary depending on your user identification number (UID) or group identification number (GID). Permissions are described in three sequences each having three characters:
UserGroupOther
rwxrwxrwx
This example (meaning that user, group, and others all have reading, writing, and execution permission to 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 chmod’s 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 make file readable and writable by the group.
The who part can be stated as one or more of the following letters:
u user’s permissions
g group’s permissions
o others permissions
The letter a (all) is equivalent to ugo 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 take away all permissions.
Permission is any compatible combination of the following letters:
r reading permission
w writing permission
x execution permission
s user or group set-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, 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. 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 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-ID and enable a file to be locked on execution at the same time. The following examples,
chmod g+x,+l file
chmod g+s,+l file
are, therefore, illegal usages and will elicit error messages.
Only the owner of a file or directory (or the super-user) may change a file’s mode. Only the super-user may set the sticky bit. In order to turn on a file’s set-group-ID, your own group ID must correspond to the file’s, and group execution must be set.
EXAMPLES
chmod a−x file
chmod 444 file
The first examples deny execution permission to all. The absolute (octal) example permits only reading permissions.
chmod go+rw file
chmod 606 file
These examples make a file readable and writable by the group and others.
chmod +l file
This causes a file to be locked during access.
chmod =rwx,g+s file
chmod 2777 file
These last two examples enable all to read, write, and execute the file; and they turn on the set group-ID.
SEE ALSO
September 02, 1992