JC Nunez
JC Nunez

Reputation: 187

Why umask 001 does not set execution permissions?

I am new to Linux. I am making some trials with the umask command. I set the umask to 001 but when I create a file and the display a long list, the new file does not show allowed-execution permission. I wonder why?

Screenshot

Upvotes: 2

Views: 4123

Answers (3)

N D
N D

Reputation: 737

It could be that the system admin has set up a umask exception to not allow execute permissions to occur by default. See this article for more information: http://boulderapps.co/on-create-a-new-file-why-are-the-execute-permissions-not-set-to-my-umask

Upvotes: 0

glglgl
glglgl

Reputation: 91017

The umask tells the system which bits to remove from the mode bitmask given at the creat() call. The umask is usually represented as an octal number, each digit consisting of 3 bits (r=4, w=2, x=1). The three octal digits stand for "user", "group", "other".

It is up to the program if it calls creat with the mode 666 for rw- or 777 for rwx. In this case, obviously 666 is used. (A file is normally created with 666 unless it is supposed to be executable. In this case, 777 is used. This counts e. g. for compilers.)

A very common umask is 022 (octal). It turns 666 (rw-rw-rw-) into 644 (rw-r--r--) and 777 (rwxrwxrwx) into 755 (rwxr-xr-x) These are, respectively, the file modes which are eventually applied to the file.

Your umask 001 would only switch off the x bit of the "others" group. So 777 would become 776 (rwxrwxrw-), and 666 stays 666 (rw-rw-rw-).

Upvotes: 1

Edgar Klerks
Edgar Klerks

Reputation: 1537

Umask is a bit special. What setting a bit means is that you are actually disabling the permission. It implementation is:

(not umask) & filemode

The filemode is what the user would like to create.

So you disabled the execution bit:

001 -> complement -> 110 -> rw- 

The mask you want to try is 110 (bits) or 006 (octal) :)

Upvotes: 1

Related Questions