chmod: Change Mode (Permissions)



next up previous contents
Next: Exercises Up: Permissions/File Access Modes Previous: Permissions/File Access Modes

chmod: Change Mode (Permissions)

The chmod command allows a user to change the permissions of a file/directory. To use chmod, the user must be the owner of the file.

The syntax of the command is:

-f and -R are options. One or both may be used.
-f
(force) will cause the command not to complain if it fails to change the permissions.
-R
(Recursively) will cause all files and directories within (underneath) the file/directory whose permissions are being changed to take those permissions.

mode may be specified as three octal values (one for each of the three sets of permissions): if any of the permissions r,w, or x bit is set, the corresponding permission is enabled: give it a 1. If not, give it a 0. Then, for each of the three permission groups, interpret the three binary numbers as an octal number.

Using the above example of the file phone.numbers, which had the rwxrwxr- permissions, it would translate to 111 111 100, or 774:

rwx rwx r-
111 111 100
7 7 4
If write permission for world (sometimes called others) is added, mode is changed to 776 (or 111 111 110).

mode may also be specified symbolically as +r which would add read permissions to everyone, or as -w which would take away write permissions from everyone (all groups).

filename(s) may be one or more filenames, and/or one or more directories, separated by blank spaces.

For example, to change the permissions on file phone.numbers, from rwxrwxr- to rwxrwxrw-, the command

chmod 776 phone.numbers
or
chmod +w phone.numbers
or (because we are changing it only in the others group)
chmod go+w phone.numbers
which means ``group others add write", could be used.

Typing the command

chmod
by itself will display the usage of the command.

Refer to the UNIX manual of your machine for more options on the command.



next up previous contents
Next: Exercises Up: Permissions/File Access Modes Previous: Permissions/File Access Modes



Super-User
Fri Feb 17 15:55:40 EST 1995