Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Based on this Serverfault question, my git user has permission in sudoers to run a wrapper script to move files into my webroot with git.

Everything is working fine except for the chmod and chown lines. After the script has run, the files are still root:root instead of apache:apache.


echo "**** Pulling changes into Prime [Hub's post-update hook]"
cd /usr/local/apache/htdocs || exit
unset GIT_DIR
git pull hub master
exec /usr/libexec/git-core/git-update-server-info
chmod -R 0644 /usr/local/apache/htdocs
chown -R apache:apache /usr/local/apache/htdocs

Since the script is running as root, why wouldn't the chmod and chown commands be working?

share|improve this question
up vote 7 down vote accepted

The chmod line is never reached as you can easily check by inserting touch /root/checkfile directly above. exec does not return into the script. I must be the last command in a script (or script's branch).

share|improve this answer
That did it. Thanks. – Ian Apr 14 '13 at 3:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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