chmod

change access permissions of a file

Command


SYNOPSIS

chmod [-fR] mode pathname ...


DESCRIPTION

chmod changes the access permissions or modes of the specified files or directories. Modes determine who can read, change or execute a file.

Options

-f

does not issue error messages concerning file access permissions, even if chmod encounters such errors.

-R

changes the access permissions of all files and subdirectories under a directory if one is specified as a path name on the command line.

Modes

You can specify the mode value on the command line in either symbolic form or as an octal value.

A symbolic mode has the form
[who] op permission [op permission ...]
The who value is any combination of the following:
u

sets user (individual) permissions.

g sets group permissions. o sets other permissions. a sets all permissions; this is the default.
The op part of a symbolic mode is an operator that tells chmod to turn the permissions on or off. The possible values are:
+

turns on a permission.

-

turns off a permission.

=

turns on the specified permissions and turns off all others.

The permission part of a symbolic mode is any combination of the following:
r

read permission. If this is off, you cannot read the file.

x

Execute permission. If this is off, you cannot execute the file.

X

Execute/search permission for a directory; or execute permission for a file only when the current mode has at least one of the execute bits set.

w

Write permission. If this is off, you cannot write to the file.

s

setuid on execution or setgid on execution permission.

t

sticky bit.

You can specify multiple symbolic modes if you separate them with commas.

Absolute modes are octal numbers specifying the complete list of attributes for the files; you specify attributes by OR'ing together these bits.
4000      setuid bit
2000      setgid bit
1000      sticky bit
0400      Individual read
0200      Individual write
0100      Individual execute (or list directory)
0040      Group read
0020      Group write
0010      Group execute
0004      Other read
0002      Other write
0001      Other execute
This list shows the first three bits with their meanings in parentheses. The MKS version of chmod tries to handle options in a way that parallels the POSIX approach. In the following list, each line shows a group of calls that are equivalent.
chmod 0000   chmod o=s
chmod 2000   chmod g=s
chmod 4000   chmod u=s
chmod 6000   chmod ug=s


EXAMPLES

chmod -w nowrite
makes file nowrite read-only.
chmod +r sysfile
sets the read-only attribute for sysfile.
chmod a=rwx file
turns on read, write, and execute permissions. This is equivalent to
chmod 0777 file

DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

Failure due to any of the following:

— unable to access a specified file
— unable to change the modes on a specified file
— unable to read the directory containing item to change
— encountered a fatal error when using the -R option
2

Failure due to any of the following:

— missing or invalid mode argument
— too few arguments

Messages

fatal error during "-R" option

You specified the -R option but some file or directory in the directory structure was inaccessible. This may happen because of permissions or because you have removed a removable disk unit.

read directory "name"

You do not have read permissions on the specified directory.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

The -f option as well as the t permission are extensions to the POSIX standard.


SEE ALSO

Commands:
lc, ls

Miscellaneous:
stat(5)


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]