Permissions, users and access

Command umask

Set default permissions for new files

Linux · Bash examples · commands run on the selected server

When to use umask

Use umask to restrict default permissions for newly created files and directories. It affects future creation within the process context; it does not repair permissions on existing files.

Syntax

umask [-S] [MASK]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-S
Show the mask in symbolic form.
027
For new files and directories, deny group write permission and all access to others.
077
Restrict new objects to owner.

Usage examples

View current mask

umask

The current mask is printed in its numeric form.

View symbolic form

umask -S

A symbolic display shows the permissions that the mask allows through.

Create a file with a restrictive mask in a subshell

(umask 077; touch ./private-notes.txt)

The restrictive mask is confined to a subshell, where a new note file is created without group or other access.

Notes and limitations

  • The mask affects newly created files and directories, not the permissions of existing ones.
  • Resulting permissions also depend on the requested creation mode and ACLs. A umask is not a chmod permission mode.

Common questions and troubleshooting

Does umask change existing files?

No. Adjust existing modes separately after inspecting their current ownership and access requirements.

Why are new files not executable with a permissive mask?

The application chooses initial requested permissions, commonly without execute bits for regular files. A mask can remove requested bits but does not add new ones.

Further help

Options vary by version and distribution. Check the installed documentation with this command: help umask.