I don't seem to be able to use umask to make sure my default file permission is 755. I need it because every time I check out a script file on CentOS from my version control, it doesn't have the x permission and I have to manually chmod +x script.sh. How to umask to get default file permission of 755? Why is the umask calculation for files based off of 666 as the maximum permission for files and not 777?


2 Answers 2


The permissions a file gets can only be reduced by the umask, so no, you can't use it to add permissions. Also, unlike you claim, the permissions before reducing the masked bits are not 0666 or 0777 but whatever the program in question sets. The usual custom is to create normal files with mode 0666 and directories with 0777 and let the umask handle limiting access for other users, but a program that is creating especially private files would use 0600 as the starting permissions.

If you need an application to create files with certain permissions, you need to fix it on the application level. For Subversion, see the svn:executable property.


An option is to create a funciton in your .bashrc (if you are using bash) that will do two things.

  1. check out the script
  2. chmod +x script.sh

    myfunction () {
    #do things with parameters like $1 such as
    checkout_command $1
    chmod +x $1
    #calls `myfunction` to checkout the script and chmod on the fly.
    myFunction my_script.sh 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .