umask

User's file creation mask. 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 (the default is an octal number)
   -p    Output in a form that may be reused as input (if mode is omitted)

The current value of the mask will be printed if mode is omitted. By default macOS will set it to 0022 (022)

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

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.

The return status is 0 if the mode was successfully changed or if no mode argument was supplied, and false otherwise.

Examples
Example values for the mask:
022, gives read and execute access to the group and others.

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:

chmod - Change access permissions
chown - Change file owner and group


Copyright © SS64.com 1999-2017
Some rights reserved