6.4. File Ownership and Permissions
6.4.4 The umask
When you create a file the system gives it a default set of permissions.
These are controlled by the system administrator and will vary from
installation to installation. If you would like to change the default
which is in effect for you, choose your own with the umask command.
Note that the permission specified by the umask setting will be
applied to the file, unlike that specified in the chmod command,
which normally only adds or deletes (few people use the = operator to
chmod).
First, issue the command without arguments to cause the current settings
to be echoed as an octal number:
If you convert these digits to binary, you will obtain a bit pattern
of 1's and 0's. A 1 indicates that the corresponding permission is to
be turned off, a 0, that it is to be turned on. (Notice that the bit
patterns for chmod and umask are reversed.) Hence, the
mask output above is 000010010, which produces a permission setting of
rwxr-xr-x (i.e., write permission is turned off for group and other).
Suppose you decide that the default setting you prefer is rwxr-x---.
This corresponds to the masking bit pattern 000010111, so the required
mask is 027:
Now, if you create a new file during this session, the permissions
assigned to the file will be the ones allowed by the mask value.