umask: set the file mode creation mask
umask [MASK]
Options you will use
-S- Print the mask in symbolic form: u=rwx,g=rx,o=rx.
Gotchas
- The mask REMOVES bits. 022 gives 644 files and 755 dirs; 027 gives 640 and 750. Directories start from 777, files from 666 - which is why new files are never executable.
- On Ubuntu a login gets 0002 (files 664, dirs 775): pam_umask turns 022 into 002 for a user whose primary group is their own (USERGROUPS_ENAB yes in /etc/login.defs). root, sudo and services keep 0022.
Taught in
Try umask in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.