Why is umask setting a different permission for a directory and file I have created Consider:

[user@server1 ~]$ umask
[user@server1 ~]$ mkdir TEST2; touch TEST2.txt;
[user@server1 ~]$ ls -l
d------rwx 2 user group_name 4096 Mar  5 05:16 TEST2
-------rw- 1 user group_name    0 Mar  5 05:16 TEST2.txt

Now shouldn't the file TEST2.txt have the permission 007 as umask is set to 0770?


3 Answers 3


umask doesn't enforce rights, it forbids them. Have a look at strace:

open("newfile", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
mkdir("newdir", 0777)                   = 0

touch doesn't ask for execution rights for a file (which wouldn't make sense).

  • Thanks Hauke for the explanation! I read here and in some other places that umask will never set the 'x' permission expect when creating a directory or compiling a program to create an executable binary.
    – Kent Pawar
    Commented Mar 5, 2013 at 11:02
  • So when we say that umask forbids rights, it means that the process creating the file might try to give the file more permissions that umask would allow. So umask will then ensure that the illegal permissions are "masked-out"? Is my understanding correct?
    – Kent Pawar
    Commented Mar 5, 2013 at 11:05
  • 1
    @KentPawar A compiler will usually ask for the execute right for a file. Indeed, as the name says: umask masks rights out. Commented Mar 5, 2013 at 11:09
  • Why can't umask set a file to be 775 by default? Is it dangerous? I can do it manually, why does it limit me here? Commented Aug 4, 2014 at 18:12

The umask value is permissions to deny, taken off whatever permissions would be given by default. A directory requires search permission, so unless overriden its permissions are 0777 (rwxrwxrwx), with the typical umask of 0002 it leaves 0775 (rwxrwxr-x). For an executable the same (x means execute here); for a regular file default permissions are no execute, rw-rw-rw- (0666), with the above umask 0664 (rwxrwxr--).


umask is a value that is basically the complement of the default permission value. So, if umask shows 002, that means the default permission is 775. Other examples for better understanding include umask=000 => perms=777 or umask=777 => perms=000 .

  • Yes, I understood that. But I could not get why the 'x' permission was taken away automatically..
    – Kent Pawar
    Commented Mar 5, 2013 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .