umask

User's file creation mask. umask sets an environment variable which automatically sets file permissions on newly created files. i.e. it will set the shell process's file creation mask to mode.

Syntax
      umask [-p] [-S] [mode]

Key
   mode  File creation mask

   -S    Print the mask in symbolic format

   -p    Output in a form that may be reused as input

The mode specified works as a mask, if mode is omitted, the current value of the mask will be printed.

You can set umask in /etc/bashrc or /etc/profile for all users. By default most Linux distros will set it to 0022 (022) or 0002 (002).

So the file will contain
umask 022

If mode begins with a digit, it is interpreted as an octal number; if not, it is interpreted as a symbolic mode mask similar to that accepted by the chmod command.

The return status is zero if the mode is successfully changed or if no mode argument is supplied, and non-zero otherwise.

Note that when the mode is interpreted as an octal number, each number of the umask is subtracted from 7. Thus, a umask of 022 results in permissions of 755.

umask is a bash built in command.

"Woe to him who doesn't know how to wear his mask, be he king or Pope!" ~ Luigi Pirandello

Related:

export - Set an environment variable
chmod - Change access permissions
chown - Change file owner and group
readonly - Mark variables/functions as readonly


© Copyright SS64.com 1999-2013
Some rights reserved