Default Permissions
Umask.
When you create a new file, it gets permissions straight away. RW, R, R. Where does that come from? A setting called the U mask.

- New files get permissions
- rw-r--r--
- Where from? The umask
Seeing the mask
U mask prints the current mask. Zero zero two two. Think of it as the permissions to take away. New files start from six six six, take away zero two two, and end up as six four four. Folders start from seven seven seven, and end up as seven five five.
umask 0022 touch new.txt && mkdir newdir ls -ld new.txt newdir -rw-r--r-- 1 sam sam 0 Jan 5 09:00 new.txt drwxr-xr-x 2 sam sam 4096 Jan 5 09:00 newdir
A stricter mask
Set the mask to zero seven seven, and new files are private from the start. Six hundred for files, seven hundred for folders. This only lasts for the current terminal. To keep it, you'd put the U mask command in your dot bash RC file.
umask 077 touch private.txt && mkdir privdir ls -ld private.txt privdir -rw------- 1 sam sam 0 Jan 5 09:00 private.txt drwx------ 2 sam sam 4096 Jan 5 09:00 privdir
Why files never get X by default
Notice new files never get execute permission, even with the friendliest mask. That's deliberate. Linux won't let a new file be run as a program, until someone decides it should, with CH mod plus X. It's one more small safety net.
| key | value |
|---|---|
| Files start at | 666, never x |
| Folders start at | 777 |
| umask 022 | 644 / 755 |
| umask 077 | 600 / 700 |
Summary
The U mask takes permissions away from new files and folders. Zero two two gives six four four and seven five five. Next, a quick permissions quiz.
Key takeaways- umask
- 022 → 644 / 755
- 077 → 600 / 700