Next: Changing file ownership
Up: Permissions
Previous: Displaying file permissions
The chmod command is used
to change the permissions for a file. Only the owner of a file or the
superuser can modify its permissions. The format of the chmod
command is
chmod ugo=rwxs
where
- the letters u, g, and o specify the category
of user: user (owner), group, and other
respectively. Omit any of these to which the permission is not
intended to apply. You may use a to mean all, i.e. equivalent to ugo.
- the letters r, w, x, and s specify the
category of permission: read, write, execute, and
set-id respectively (replace s by t if the
permission applies to other). Omit any of these permissions which
are not being granted.
- Use = to set file's permissions to exactly the
ones that are specified.
- Replace = by + to add the specified
permissions to those the file already has.
- Replace = by - to remove the specified
permissions from those the file currently has.
For instance,
chmod a+x foo.pl
adds execution permission for all three categories of users to file
foo.pl.
chmod o-rwx private
denies all access to directory private to users other than its
owner or members of its group.
For convenience, those who know the octal number system can use a
numeric code to specify permissions. To define the octal number,
each of the three rwx fields corresponds to one digit. If r is present, the digit contains a 4, if w is present, the
digit contains a 2, and if x is present the digit contains a 1.
These three numbers are summed to produce the octal digit. For
instance
chmod 750 bar
sets the permission of bar to rwxr-x---. (The octal method
can also be used to set the set-id permissions. See the chmod
man page for details.)
Next: Changing file ownership
Up: Permissions
Previous: Displaying file permissions
Robert Moniot
2000-09-13