Skip to content

Instantly share code, notes, and snippets.

@jstrosch
Last active January 1, 2016 09:59
Show Gist options
  • Save jstrosch/8128531 to your computer and use it in GitHub Desktop.
Save jstrosch/8128531 to your computer and use it in GitHub Desktop.
Script to set proper file permissions on a drupal installation.
#!/bin/bash
echo "Type the directory from /var/www, followed by [ENTER]:"
read dir
cd /var/www/$dir
echo "Updating owners..."
#TODO: change
#chown -R #:www-data .
find . -type d -exec chmod u=rwx,g=rx,o= {} \;
find . -type f -exec chmod u=rw,g=r,o= {} \;
cd sites
echo "Changed to:"
pwd
find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
find . -name files -type d -exec find '{}' -type f \; | while read FILE; do chmod ug=rw,o= "$FILE"; done
find . -name files -type d -exec find '{}' -type d \; | while read DIR; do chmod ug=rwx,o= "$DIR"; done
echo "Permissions Updated!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment