$linuxjunkies
>

umask(1)

Set or display the file mode creation mask that determines default permissions for new files and directories.

UbuntuDebianFedoraArch

Synopsis

umask [-p] [-S] [mask]

Description

The umask command controls the default permissions assigned to newly created files and directories. It works by subtracting the mask value from the maximum permissions (666 for files, 777 for directories). The mask is typically represented as a 3 or 4-digit octal number where each digit controls permissions for owner, group, and others.

When invoked without arguments, umask displays the current mask. When given a mask argument, it sets the mask for the current shell session. Changes to umask only affect the current shell and processes spawned from it; they do not persist across login sessions unless set in shell configuration files like .bashrc or .profile.

Common options

FlagWhat it does
-SDisplay the mask in symbolic format (e.g., u=rwx,g=rx,o=rx) instead of octal
-pOutput in a format suitable for re-input as shell commands (umask mask)

Examples

Display the current umask value in octal notation

umask

Display the current umask in symbolic format for better readability

umask -S

Set umask to 0022, giving new files 644 permissions and directories 755 permissions

umask 0022

Set restrictive umask so new files are readable only by owner (600) and directories only by owner (700)

umask 0077

Display the current umask in a format that can be saved to shell configuration files

umask -p

Set umask to 0002 for group-friendly permissions: files get 664, directories get 775

umask 0002

Related commands