Back to the command reference

umask

FilesAdvanced In simulator In real Linux

Set the default permission mask for new files

Name: umask = user file-creation mask

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

umask is a shell builtin that sets which permission bits are removed from new files and directories. Files start from 666 and directories from 777, minus the mask: with umask 022 you get 644 files and 755 directories.

It affects the current shell and its children; put it in ~/.bashrc to make it permanent.

Syntax

umask [-S] [MASK]

Common options

-SShow symbolically, e.g. u=rwx,g=rx
-pPrint it as a command you can run (umask 0022)
022Common value: new files 644, directories 755

Examples

  • $ umask

    Show the current mask

    Explain
  • $ umask 077

    New files are private to you from now on

    Explain

Related