The syntax of the command is:
chmod [-R] mode filename(s)-R is an option.
mode may be specified as three octal values (one for each of the three sets of permissions): if any of the permission bits r,w, or x 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.
Another way to explain it is to give different weighing factors to the different permissions: 4 to ``r", 2 to ``w", and 1 to ``x". If the permission is set, add the weighing factor. Otherwise do not add anything to the group value.
Using the above example of the file phone.numbers, which had the rwxrwxr- permissions, it would translate to 111 111 100, or 774, or 4+2+1 4+2+1 4+0+0:
rwx rwx r-If write permission for world (sometimes called others) is added, mode is changed to 776 (or 111 111 110, or 4+2+1 4+2+1 4+2+0).
111 111 100
7 7 4
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.numbersor
chmod +w phone.numbersor (because we are changing it only in the others group)
chmod go+w phone.numberswhich means ``group others add write", could be used.
The general syntax, using the conventional method is
chmod [ugo]+-[rwx] filename(s)Where
Any combination of ugo, rwx may be used. If none is used, then all three are assumed. One exception: if chmod - is used, the result depends on the value of umask (umask sets the default permissions on files; usually 022 at NRC - see man page for details).
It is also acceptable to put a combination of ``[ugo]+-[rwx]", as long as they are separated by a comma (,), as in
chmod ug+x,o-x filename.
Typing the command
chmod -help (linux)by itself will display the usage of the command.
chmod (generic UNIX)
Refer to the UNIX manual of your machine for more options on the command.