I am trying to learn how to use umask but it seems so complicated.
Besides all the subtractions that I have to make in my head seperately for directories and files every time I see a mask value, the umask seems different at different times(see bellow).
For example if I have a mask of
umask
0002
it can also be seen as
umask -S
u=rwx,g=rwx,o=rx
Why does the umask give rwxrwxr-x
and not -------w-
in this case? When I am given 0002 I am supposed to calculate the permissions for files by 666-002 and directories by 777-002. Shouldn't then umask -S
give me a similar thing so that I can calculate with. For example negation-of(-------w-)
. So in one case it acts as a mask for negation and in the second case it just gives the result from what I understand. Why this ambiguous behaviour?