umask: changing the default directory and file access

The file mode that is used for a new directory or a new file is determined by the current setting of the umask. The following table indicates the file modes that would be set for some values of the umask:

       umask      directory        file
        000       rwxrwxrwx      rw-rw-rw-
        022       rwxr-xr-x      rw-r--r--
        027       rwxr-x---      rw-r-----
        077       rwx------      rw-------
        777       ---------      ---------

The standard .cshrc file sets the umask to 077. This is the reason that new directories have a file mode of rwx------ and new files have a file mode of rw-------. The command umask can be used to display the current value of the umask or to change the setting that is used.

For example, suppose you wish any new directories to be both readable and searchable and any new files to be readable by members of your group. To avoid having to use the chmod command on each directory and file, you can type the command:

umask 027

The file mode of any new files will be rw-r---- and any new directories will be rwxr-x---.

Or if you wish any new files and directories automatically to be readable by members of your group and any other users, use the command:

umask 022

If you wish such a umask command to be executed everytime you start a new C-shell, you should add the appropriate umask command to the end of your .cshrc file.