View and set the default file permission umask on Linux

The forgotten octal that decides how open every new file is — run `umask` to see it, `umask 027` to tighten it for this shell.

LinuxumaskdefaultpermissionsLow risk
Run bare `umask` to print the current mask and `umask 027` so new files are 640 and new directories 750.

01Command

Command
$ umask 027

02What it does

The umask is subtracted (bitwise cleared) from the mode requested at creation: with umask 027, files become 640 (rw-r-----) and directories 750 — group-readable but closed to everyone else. It's per-process and inherited, so a one-off `umask 027` affects only that shell; to make it stick, set it in ~/.bashrc, /etc/profile, or PAM's umask setting. Create files under the new mask without touching your shell using `(umask 027; touch secret.txt)`.

03Risk

RiskLow risk
!Warning: chmod fixes existing files, umask fixes future ones — changing umask does not retroactively alter any file already on disk.

04Undo

Undo
$ umask 022

05Sources

  • umask(2) — set file mode creation mask
    man7.org · technical · 2026-09-17
    Evidence: Explains that umask bits are cleared from requested permissions when files are created, and that the mask is inherited by children.

Last verified: 2026-09-17 · Category: Security & Privacy

06Related solutions