On create a new file, why are the execute permissions not set to my umask

Why newly created files do not have the execute permissions set by default, even though I set default permissions to have execute with the command umask?

Example (reason why below):

Lets say you have run the following command:

[local_username@localhost /]$ umask 0002

This sets your default permissions to 775 otherwise known as rwxrwxr-x

Then you run the following commands:

[local_username@localhost /]$ touch new_file
[local_username@localhost /]$ ls -d -l new_file
-rw-rw-r--. 1 local_username local_username 0 Oct 22 16:34 new_file

The question is...why does the new file have the permission -rw-rw-r-- when it's umask is set to rwxrwxr-x?

Reason:

The reason for this is it is common for most systems to set an override that makes is so all new files do not have the execute privileges. This is to keep an intruder from being able to write and execute their own scripts without the rights to chmod u+x new_file.


However on these systems you should be able to do mkdir and the execute permissions will default to your umask.

comments powered by Disqus