UMASK, short for User Mask, is a command-line utility and shell setting in Unix-like operating systems, including Linux and macOS, used to define default file and directory permission masks for newly created files. Developed as part of the original Unix system in the 1970s, UMASK determines which permission bits are disabled when new files or directories are created. It is accessible via terminal shells such as bash or zsh, and documentation can be found using man umask or the GNU UMASK Manual.
UMASK exists to provide a convenient way to enforce security policies and default permissions for users and processes, preventing overly permissive access by default. Its design emphasizes simplicity, safety, and predictability, allowing system administrators and users to control file creation behavior consistently across scripts, interactive sessions, and automated workflows.
UMASK: Understanding the Mask
The umask value subtracts permissions from the default full permissions (666 for files, 777 for directories), using octal notation.
# set default mask so new files are readable/writable by owner and group, none for others
umask 002
# set default mask so new files are readable/writable only by owner
umask 077This approach ensures that newly created files and directories automatically inherit secure permissions. It is closely related to CHMOD and Unix File Permissions concepts.
UMASK: Viewing the Current Mask
Users can display the current mask with the umask command without arguments.
# display the current umask
umask
# example output: 0022 (files: 644, directories: 755)Viewing the mask helps administrators and users verify the default permission policies, enabling consistent security across sessions. It complements explicit CHMOD and CHOWN operations.
UMASK: Temporary and Persistent Masks
UMASK can be set temporarily in a shell session or persistently in configuration files like ~/.bashrc or /etc/profile.
# temporary mask for current session
umask 027
# add persistent mask in ~/.bashrc
echo 'umask 027' >> ~/.bashrcTemporary masks are useful for session-specific security adjustments, while persistent masks enforce consistent default permissions across logins. This is commonly paired with scripting and deployment workflows that rely on predictable permission behavior.
UMASK is used in system administration, user configuration, and secure deployment processes on Unix-like systems. By setting default permissions automatically, it reduces the risk of unintentional access, complementing CHMOD and CHOWN for comprehensive permission management.