Umask
What in the heck is it? How does it work?
The umask is a way to determine for a given user what the permissions of newly created files and directories have. Supposedly Linux wants 666 and 777 to be default perms for files and directories, respectively. Notice when you make a file, it’s set to 644, and directories to 755 though. That’s because this umask value is taking effect. On my machine anyway, the default umask is 022 (—-w–w-). Let’s put those together:
rw-rw-rw- << file (666)
----w--w- << umask (022)
rw-r--r-- << difference
Here’s an example with a directory:
rwxrwxrwx << dir
----w--w- << mask
rwxr-xr-x << difference
You set the mask to determine which permission type to BLOCK or NULLIFY. If the mask has a particular bit set, that means it blocks that particular bit from being in effect in the result.
For fun, let’s set a different umask: 0200
rw-rw-rw- << file
-w------- << umask
r--rw-rw- << difference
So let’s take it a step further and see what happens when we’re using the decimal versions:
666 << file
200 << mask
355 << difference
I’ll admit, it really doesn’t make sense when doing it with just the numbers.