chmod - Changes permission codes
chmod [-fR] absolute_mode file...
chmod [-fR] [who]+permission ... file...
chmod [-fR] [who]-permission ... file...
chmod [-fR] [who] = [permission]... file...
command modifies the read, write, and execute
permissions of specified files and the search permissions of specified directories.
Interfaces documented on this reference page conform to industry standards as follows:
chmod: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
[Compaq] Does not report an error if
fails to change the mode on a file.
to recursively descend its
directory arguments, setting the mode for each file as described in the sections
When symbolic links are encountered, their mode is not changed and they are
Pathname of the file that is to have the permission bits modified.
the file permissions. This code is formed as described under
Specifies whether permissions are being defined for a user,
group, or all others. This operand is more fully described under
Specifies the operation to be performed on the permissions
being defined. This operand is more fully described under
Specifies the permissions being defined. This operand is
more fully described under
You can use either symbolic or absolute mode to specify the desired permission settings.
You can change the permission code of a file or directory only if you own it or if you have superuser authority.
[Compaq] If a named file is a symbolic link,
changes the mode of the link's target file unless the
is used. If the
option is used,
leaves links and their target files untouched.
A symbolic mode has the form: [who] operation permission [operation permission] ...
The who argument specifies whether you are defining permissions for a user, group, or all others, or any combination of these. The operation argument specifies whether the permission is being added, taken away, or assigned absolutely. The permission argument identifies the operation that the specified users can perform on file.
Valid options for the who argument are as follows: User (owner) Group All others User, group, and all others (same effect as the combination ugo)
[Compaq] If the who argument is omitted, the default is a, but the setting of the file creation mask, umask (see umask(1), csh, ksh, sh), is applied.
Valid options for the operation argument are as follows: Removes specified permissions. Adds specified permissions. Clears the selected permission field and sets it to the code specified. If you do not specify a permission code following =, chmod removes all permissions from the selected field.
Valid options for the permission argument are as follows: Read permission. Write permission. Execute permission for files, search permission for directories. Execute permission only if file is a directory or at least one execute bit is set. Set-user-ID or set-group-ID permission.
The u, g, and o options indicate that permission is to be taken from the current mode. Omitting permission is only useful with = to take away all permissions.
All permission bits not explicitly specified are cleared.
You can specify multiple symbolic modes, separated with commas. Do
not separate items in this list with spaces. Operations are performed in
the order they appear from left to right.
Absolute mode lets you use octal notation to set each bit in the permission code. The chmod command sets the permissions to the permission_code you provide. The permission_code is constructed by combining (logical OR) the following values: Sets user ID on execution. Sets group ID on execution. [Compaq] Sets the sticky bit, which does the following: [Compaq] Retains memory image after execution (executable file) [Compaq] Restricts file removal (directory file)
[Compaq] The root of the directory tree that contains the commands modified for SVID 2 compliance is specified in the file /etc/svid2_path. You can use /etc/svid2_profile as the basis for, or to include in, your .profile. The file /etc/svid2_profile reads /etc/svid2_path and sets the first entries in the PATH environment variable so that the modified SVID 2 commands are found first.
[Compaq] The SVID 2 compliant version of the
command ignores the
is not specified in the symbolic mode of the command (chmod
permission). In other words, if you omit
command line, the version of the command
that is compliant with the SVID 2 standard behaves exactly as if you specified
as the value for
who. The version of the
is SVID 2 compliant also supports equivalents in absolute mode for the
permission in symbolic mode. In absolute mode, setting
the bits 04000 represents set-user-ID and setting the bits 02000 represents
The correspondence between octal value and mode bit is given in the following table.
|Octal Value||Symbolic Mode||Meaning|
|S_ISUID||4000||set user id on execution|
|S_ISGID||2000||set group id on execution|
|S_IRUSR||0400||read permission: owner|
|S_IWUSR||0200||write permission: owner|
execute/search permission: owner
|S_IRGRP||0040||read permission: group|
|S_IWGRP||0020||write permission: group|
execute/search permission: group
|S_IROTH||0004||read permission: other|
|S_IWOTH||0002||write permission: other|
execute/search permission: other
The following exit values are returned:
An error occurred.
To add a type of permission to several files, enter: chmod g+w chap1 chap2
The following environment variables affect the execution of
Provides a default value for the internationalization variables
that are unset or null. If
is unset or null, the corresponding value from the default locale is used.
If any of the internationalization variables contain an invalid setting, the
utility behaves as if none of the variables had been defined.
If set to a non-empty string value, overrides the values of
all the other internationalization variables.
Determines the locale for the interpretation of sequences
of bytes of text data as characters (for example, single-byte as opposed to
multibyte characters in arguments).
Determines the locale for the format and contents of diagnostic
messages written to standard error.
Determines the location of message catalogues for the processing
[Compaq] Defines the correspondence between symbolic codes
and octal mode values.
Commands: chgrp(1), chown(1), csh(1), ksh(1), ls(1), Bourne shell sh(1b), POSIX shell sh(1p), umask(1)
Functions: chown(2), chmod(2), stat(2), umask(2)