Skip to content

Instantly share code, notes, and snippets.

@jhafner
Created May 7, 2012 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhafner/2630387 to your computer and use it in GitHub Desktop.
Save jhafner/2630387 to your computer and use it in GitHub Desktop.
Setting Files to 755 and Directories to 644 - Bash Script
for i in $(find /home/*/public_html -maxdepth 0); do u=$(echo $i | awk -F '/' '{print $3}') && chown -R $u:$u $i; done
for i in $(grep DocumentRoot /usr/local/apache/conf/httpd.conf | awk '{print $2}' | grep -v /usr/local/apache/htdocs); do chgrp nobody $i; done
find /home/*/public_html -type d -exec chmod 755 '{}' ';'
find /home/*/public_html -type f -exec chmod 644 '{}' ';'
find /home/*/public_html -iwholename '*.cgi' -exec chmod 755 '{}' ';'
find /home/*/public_html -iwholename '*.pl' -exec chmod 755 '{}' ';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment