Bash.Builtin.Umask (Bash v0.6.0)

Copy Markdown View Source

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

Display or set the file mode creation mask.

Options:

  • No args: display the current file mode creation mask in octal
  • -S: display in symbolic form (u=rwx,g=rx,o=rx)
  • -p: display in a form that can be reused as input
  • mode: set the file mode mask to the specified mode (octal or symbolic)

The default umask is 0022 (files get 644, directories get 755).

Octal Mode

The mask is specified as an octal number (e.g., 022, 077, 0000). The mask determines which permission bits are turned OFF when creating files.

Symbolic Mode

Symbolic mode is specified as [ugoa][+-=][rwxXst]:

  • u: user/owner
  • g: group
  • o: other
  • a: all (ugo)

Example: u=rwx,g=rx,o=rx sets umask to allow rwx for user, rx for group/other.

Reference: https://cgit.git.savannah.gnu.org/cgit/bash.git/plain/builtins/umask.def?h=bash-5.3