In this video you'll learn about umask and how it is used to set default permissions.
So the umask is a shell setting that defines a mask that will be subtracted from the default permissions.
It's normally set from the shell startup files, etc profile and etc bashrc.
And to understand it, default permissions on directories are 777 and default permissions on false are 666.
Now if you use the umask of 022, which is pretty common, it
will set default permissions on false to 644 and on directories to 755.
And if you have the umask of 027, it will set default permissions on directories to 750 and on valves to 6, 4, 0.
Let me demonstrate.
I'm typing umask and now we can see that umask in fact it's four digits.
The first digit is for the special permissions. You do not ever want
to modify your special permissions through a umask. It really doesn't make sense.
So ignore it. Pretend as if it's not here.
Now the result is that when I use touch file 1 LS
L on file 1 has a permission mode set to 644.
Now when I change my umask to 0 to 7, I
verify using the umask, it's set to 0 to 7.
And I use touch file 2 and LS L on file 2 is showing that others has no permissions anymore.
If you want your umask to be effective, you need to set it through one of these shell startup files.
But be careful, because if you set 0 to 7, for
instance, that means that others in no case will have read
permissions to files anymore. And that might seriously mess up stuff.
If I may give you an advice, leave your umask alone. Your distribution is setting the umask the right way in most
cases. So leave it alone. Don't mess with it, because you might be in for some nice troubleshooting if you do.