3

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?

1

That's just how the behavior of umask is defined:

If -S is specified, the message shall be in the following format:

"u=%s,g=%s,o=%s\n", , ,

where the three values shall be combinations of letters from the set { r, w, x}; the presence of a letter shall indicate that the corresponding bit is clear in the file mode creation mask.

(from http://pubs.opengroup.org/onlinepubs/9699919799/utilities/umask.html)

It seems logical that being able to display the mask in both forms would be useful, though admittedly the umask(1) man page is not terribly clear on what the -S option does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.