I've made a Makefile to simplify my life, and this Makefile calls a script in a bin file I've created. After running my command make something, I got following error :

/bin/sh: 1: .docker/bin/echo-title: Permission denied

After searching a bit and thanks to this answer, I gave execute permission to the user who created the file (aka: me) with chmod command. My question is : Since I'm the owner of the file, shouldn't I have execute permission right away? And if not... why?

This is for a personal project, but at work we're also using Makefiles and bin scripts, exactly this way (I actually copied and pasted the base content of the files) and I don't have to run a chmod command to run the scripts. Why is that so?

(Running other commands in the Makefile that don't involve bin script work well.)


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 the permissions a particular application uses when creating a file, typically 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.


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?

| improve this answer | |
  • Thanks for these explanations (and for the resources)! I've just run the command and indeed, my umask value is 002. I'm guessing then that at work it's not the same. I'll run umask there to confirm that. – Chloé Dec 20 '19 at 17:39
  • 3
    Not quite right. The umask masks whatever permissions the process supplies when creating the file. It is not required that applications use 0666 or 0777. That is merely common. – JdeBP Dec 20 '19 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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