chmodchange access permissions of a file |
Command |
chmod
[-fR
] mode
pathname ...
chmod
changes the access permissions or modes of the
specified files or directories. Modes determine who can read, change or execute
a file.
-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.
The who value is any combination of the following:[who] op permission [op permission ...]
u
sets user (individual) permissions.
g
sets group permissions. o
sets other
permissions. a
sets all permissions; this is the default.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.
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.
This list shows the first three bits with their meanings in parentheses. The MKS version of4000 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
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
makes filechmod -w nowrite
nowrite
read-only.
sets the read-only attribute forchmod +r sysfile
sysfile
.
turns on read, write, and execute permissions. This is equivalent tochmod a=rwx file
chmod 0777 file
0
Successful completion.
1
Failure due to any of the following:
-R
option2
Failure due to any of the following:
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.
You do not have read permissions on the specified directory.
-f
option as well as the t
permission are extensions to the POSIX standard.
stat(5)