Skip to content

Instantly share code, notes, and snippets.

@pichuang
Created February 7, 2015 03:55
Show Gist options
  • Save pichuang/ebb0d9d412185d064469 to your computer and use it in GitHub Desktop.
Save pichuang/ebb0d9d412185d064469 to your computer and use it in GitHub Desktop.
Easy Change WWW Permission
#!/bin/bash
USER="http"
GROUP="http"
DIR_PERMISSION="750"
FILE_PERMISSION="640"
DIRPATH="$1"
if [ $# == 0 ]; then
echo "Usage: changePerm.sh DIR"
elif [ -d $DIRPATH ]; then
echo "Processing owner"
find $DIRPATH \! \( -user $USER -and -group $GROUP \) -exec chown $USER\:$GROUP '{}' +
echo "Processing permission"
find $DIRPATH -type d \! \( -perm $DIR_PERMISSION \) -exec chmod $DIR_PERMISSION '{}' +
find $DIRPATH -type f \! \( -perm $FILE_PERMISSION \) -exec chmod $FILE_PERMISSION '{}' +
else
echo "You need a dir"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment