0

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?

1

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.

| improve this answer | |
0

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 
    
| improve this answer | |

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.