Skip to content

Did you know?

umask decides the permissions every new file gets.

With 022 new files are 644 and directories 755; with 002 they are 664 and 775.

Explained

New files start with permissions 666 (read and write for everyone) and new directories with 777. The umask lists the permission bits to take away. Show yours:

umask
umask -S
0022
u=rwx,g=rx,o=rx

With 022, write permission is removed for the group and others, so new files are 644 (rw-r–r–) and directories 755. Many distributions give regular users 002 instead when each user has a private group, which lets the group write too: 664 and 775.

To create private files by default, for example on a shared server, set a stricter mask in ~/.bashrc:

umask 077

New files are then 600 and directories 700. For services, set the mask in the systemd unit with UMask=0027 rather than changing permissions afterwards. And when something “only works with chmod 777”, the real fix is the right owner and group, not wider permissions.

Learn more

← All tech tips · Suggest a fix

Back to top