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:
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-digit octal number> <filename/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:
The umask command changes the default protection mode for all
files and directories subsequently created. umask is initially called
from within the .cshrc initialization file to set your default protection value.
To use umask, you provide a three-digit octal number that has bits
set where you want permissions to be removed:
umask 033
mkdir pascal
The directory pascal will be created with the following mode:
umask 077 (the usual setting in .cshrc)gcc -o life life.c (produces an executable file, life)
The file life will have the following protection mode: