Every UNIX file has a protection mode associated with it. Listing the contents of a directory with ls -l command displays the protection mode for each file. The mode is composed of ten flags divided into four groups:
| 1cDirectory | 1cUser | 1cGroup | 1cOthers |
| d | rwx | rwx | rwx |
The Directory flag indicates whether or not a name represents a directory. User is a category that refers to the file/directory owner. The category Group refers to a group of users that you might belong to, such as COS398. This protection category is provided because you may wish to let other users in your group have access to certain files, but exclude people outside of that group. Others refers to all the other users that aren't you, or members of your group.
The three permission types are read, write, and execute. To change permissions:
chmod ugo
rwx filename/directoryname
*or *
chmod 3-digitoctalnumberfilename/directoryname
The first form uses the 'u','g', and 'o' characters to specify user, group, and others, respectively. By typing the following,
chmod go-w afile1
the write privileges are removed from the group and others. Other combinations which add and subtract privileges at once are possible:
chmod o+r-w afile1
This allows others to read afile1 , but not write to it.
The second form of chmod is the absolute form, which uses octal digits to define the permission mode. Each octal digit represents the three modes of the user, group, and other categories. Each bit within the octal digit corresponds to the read, write, and execute flags.
chmod 755 afile1
The above command would change a file so that it had the following permission mode:
| 1cDirectory | 1cUser | 1cGroup | 1cOthers |
| rwx | r |
r |