Making new files automatically executable? Making new files automatically executable? unix unix

Making new files automatically executable?


umask for files is subtracted from 666 and for directories it is subtracted from 777. So if your umask is 002 and you create a directory, you get 775 (777 - 002), and if you create a file you get 664 (666 - 002).


The umask merely subtracts default file and directory permissions.

777 initial file permissions111 execute bit is not set by default---666 default file permissions022 subtract default Unix umask---644 voila, final file permissions

The execute bit must be set for the owner to cd into a directory of their creation, so user-execute permission is set, resulting in directory permissions of 744, when using the above umask.

I have found no way to setting which would set the execute, by default. This would be bad mojo, anyway, but I am currently researching for a cyber security course I am writing.


In a safe way? No.In an unsafe manner: just change the umask by adding umask xxx in your ~/.bashrc file, where xxx represents the permission mask you wish.

Notes:

  1. This is unsafe (did I already mention it? Other did.)
  2. It may leads to many issues. One being the creation of filesdisallowed on some systems)

Recommended way:

Only do it for files that actually need the execute permission.

chmod +x /the/file