|CHMOD(1)||General Commands Manual||CHMOD(1)|
chmodutility modifies the file mode bits of the listed files as specified by the mode operand. The mode of a file dictates its permissions, among other attributes.
The options are as follows:
-Roption is also specified, symbolic links on the command line are followed. Symbolic links encountered in the tree traversal are not followed.
-Roption is also specified, all symbolic links are followed.
-Roption is also specified, no symbolic links are followed.
Symbolic links have modes, but those modes have no effect on the
kernel's access checks. The
-P options are
ignored unless the
-R option is specified; if none
of them are given, the default is to not follow symbolic links. In addition,
these options override each other and the command's actions are determined
by the last one specified.
Only the file's owner or the superuser is permitted to change the mode of a file.
chmodnnnn file ...
An absolute mode is an octal number (specified as nnnn, where n is a number from 0 to 7) constructed by ORing any of the following values:
In addition to the file permission modes, the following mode bits are available:
The execute bit for a directory is often referred to as the “search” bit. In order to access a file, a user must have execute permission in each directory leading up to it in the filesystem hierarchy. For example, to access the file /bin/ls, execute permission is needed on /, /bin, and, of course, the ls binary itself.
chmod[who]op[perm],... file ...
The who symbols indicate whose permissions are to be changed or assigned:
Do not confuse the ‘o’ symbol with “owner”. It is the user bit, ‘u’, that refers to the owner of the file.
The op symbols represent the operation performed, as follows:
The perm (permission symbols) represent the portions of the mode bits as follows:
Each clause (given in a comma-delimited list on the command line) specifies one or more operations to be performed on the mode bits, and each operation is applied in the order specified.
Operations upon the “other” permissions (specified by the symbol ‘o’ by itself), in combination with the perm symbols ‘s’ or ‘t’, are ignored.
chmodutility exits 0 on success, and >0 if an error occurs.
$ chmod 644 file
Deny write permission to group and others:
$ chmod go-w file
Set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set:
$ chmod =rw,+X file
Make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone:
$ chmod +X file
Any of these commands will make a file readable/executable by everyone and writable by the owner only:
$ chmod 755 file $ chmod u=rwx,go=rx file $ chmod u=rwx,go=u-w file
Clear all mode bits for group and others:
$ chmod go= file
Set the group bits equal to the user bits, but clear the group write bit:
$ chmod g=u-w file
chmodutility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification.
The flags [
-HLP] are extensions to that
The ‘t’ perm symbol (sticky bit) is marked by IEEE Std 1003.1-2008 (“POSIX.1”) as being an X/Open System Interfaces option.
chmodcommand appeared in Version 1 AT&T UNIX.
|March 13, 2015||OpenBSD-5.8|