Skip to main content
2 of 3
added 444 characters in body
jesse_b
  • 41.6k
  • 14
  • 108
  • 163

It's not recommended to give all newly created files execute permissions as most files don't need to be executed.

umask(2) is used to determine what the default file permissions will be. If you just run umask with no options it will print the current value for your user. This is the value that will be subtracted from 666 (rw-rw-rw-) permissions for files or 777 (rwxrwxrwx) permissions for directories.

So if your umask value is 002 (pretty common) then when you create a new file it will get permissions of 664 (rw-rw-r--).

You can modify the default umask value by running umask new_value ie: umask 044, although since you can only subtract from 666 for files you won't be able to use it to default execute. Also to make it persistent you would need to add that to your rc or profile config file.

Related:

Why doesn't umask change execute permissions on files?
How umask works
how to give execute permission by umask
Why does umask 077 not allow the user to execute files/directories?

jesse_b
  • 41.6k
  • 14
  • 108
  • 163