umask — Set or return the file mode creation mask
Purpose
umask sets the file-creation permission-code mask of the invoking process to the given mode. You can specify the mode in any of the formats recognized by chmod; see chmod — Change the mode of a file or directory for more information.
The file-creation permission-code mask (often called the umask) specifies the restrictions on the permissions for any file created by the process and plays a part in determining how permission bits are changed.
- If a permission bit in the umask is on, the corresponding bit in the actual permissions will be off.
- If a permission bit in the umask is off, the corresponding bit in the actual permissions will be as the program requested.
Therefore, the umask is used to screen out
permissions that a program may request.
The umask does not affect other mode values, such as set-user-ID, set-group-ID, and the
sticky bit.
umask a=rx
You have explicitly set it so that all users have read and execute access. If you were to look at
the mask, it would be 0222. The write bit is set, because write is not allowed. If everyone were
permitted rwx access, the umask would be 0000. For example, if a command attempts to create
new files with permissions of w for all, and the umask was 0222 as above, the w permissions
would not be set.If you call umask without a mode argument, umask displays the current umask.
Options
- –S
- Displays the umask in a symbolic form:
giving owner, group and other permissions. Permissions are specified as combinations of the letters r (read), w (write), and x (execute).u=perms,g=perms,o=perms
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
Exit Values
0- Successful completion
1- Failure due to an incorrect command-line argument, or incorrect mode
Portability
POSIX.2, X/Open Portability Guide, UNIX systems.
Related Commands
chmod