umask flags & options

View current umask

Show the current file creation mask.

umask

-S

Show the mask in symbolic form.

umask -S

Set umask (octal)

Common masks: 022 (default), 077 (private), 002 (group-writable).

umask 022
umask 077
umask 002

How it works

The umask is subtracted from the maximum permissions. Files max at 666, directories at 777.

umask 027

With 027: files get 640 (rw-r-----), directories get 750 (rwxr-x---).

Set for a single command

Use a subshell to limit scope.

(umask 077; touch secret.txt)

Symbolic mode

umask u=rwx,g=rx,o=

Make permanent

Add to shell config for persistent settings.

echo "umask 022" >> ~/.bashrc