Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


[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 ?


share|improve this question
See How does gcc handle file permissions? – Gilles Mar 5 '13 at 22:06
up vote 4 down vote accepted

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).

share|improve this answer
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 Mar 5 '13 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 Mar 5 '13 at 11:05
@KentPawar A compiler will usually ask for the execute right for a file. Indeed, as the name says: umask masks rights out. – Hauke Laging Mar 5 '13 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? – Jake Wilson Aug 4 '14 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--).

share|improve this answer

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 .

share|improve this answer
Yes, I understood that. But I could not get why the 'x' permission was taken away automatically.. – Kent Pawar Mar 5 '13 at 11:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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