0

I am a beginner at OSX/Unix command line.

I have a GIT repository that was created on my OSX computer. Recently I cloned the repo and went to run a bash script within the repo via ./BashFile.sh. This is giving me a permission denied error. So i ran chmod 777 ./BashFile.sh. The next time I ran ./BashFile.sh it worked, except the bash file calls other files within it that then had "Permission Denied" errors. I then logged into a terminal session as super user via sudo -s and ran the ./BashFile.sh command, but I am still getting permission denied errors.

How should I fix this, do I need to recursively chmod 777 the entire repo directory? Why does using Sudo not let me have permission?

One thing to note, is that when I originally created the repo on my computer, I could run all the commands without a problem. Since cloning the repo I have been having permission denied errors.

1 Answer 1

0

You cannot directly execute a file that does not have the execute permission bit set. Using sudo will allow you to (attempt to) execute a file that has any execute bit set at all, but if no execute bit is set, you will get "permission denied", no matter who you run as.

You can check whether git thinks the file permissions are different from what they should be by running git status - it will show files as modified if they changed permissions; if that's it, you can fix it as described on stackoverflow.

If git thinks everything's fine, but permissions between your source and your clone repository differ, maybe you're using some odd filesystem that's confusing git's notion of what permissions the files should have, or maybe you have a git config option set (see an older answer to the same question). Whatever the cause, you need to do the same thing: copy the original permissions and apply them to your clone; this was previously answered here.

You must log in to answer this question.

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