When a file or directory is created, its initial permissions are determined by a setting called umask . A umask is a value similar to an absolute mode that is subtracted from full permissions to determine the permissions. A typical umask would be 022 or 002. Chapter 7, "Configuring Your Environment with Unix," explains how to see, and change, your umask . You may see umask s displayed as one- or two-digit numbers ; in those cases, assume that zeros are added to the left, so a umask of 2 is really 002.
"Full permissions" for files are considered to be 666 (readable and writable by everyone) and for directories to be 777 (readable, writable, and executable by everyone). You always have to explicitly change a file's permission to make a non-directory file (such as a script) executable.
The net result is that if you have a umask of 022, for example, and create a new directory, the permission on the directory is 755 (777 022), and if you create a new file, the permission is 644 (666 022).
Table 8.8 shows the effect of various umask s on the creation of new files and directories.
UMASK | F OR F ILE | F OR D IRECTORY |
---|---|---|
022 | 644 ( rw-r--r-- ) | 755 ( rwxr-xr-x ) |
002 | 664 ( rw--rwr-- ) | 775 ( rwxrwxr-x ) |
077 | 600 ( rw------- ) | 700 ( rwx------ ) |
066 | 622 ( rw------- ) | 733 ( rwx--x--x ) |