Last active
December 13, 2015 22:49
-
-
Save HomenSimpsor/4986863 to your computer and use it in GitHub Desktop.
Ensure permissions commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make all files 666, all directories 777 | |
# (remove execute, re-set directory-only execute) | |
# [may not work] | |
chmod -R -v a-x+rwX . | |
# all files 666, all directories 755 | |
find $item -type f -print0 | xargs --no-run-if-empty -0 chmod 644 | |
find $item -type d -print0 | xargs --no-run-if-empty -0 chmod 755 | |
# chmod and chown | |
find $item -type f -name '.htaccess' -print0 | xargs --no-run-if-empty -0 -I {} sh -c 'chmod 644 "{}"; chown $USER:$USER "{}";' | |
# test that all files are their proper permissions | |
find . -type f ! -perm 777 -print0 | xargs --no-run-if-empty -0 stat -c "%a %n" | |
# chown to original user while su'd (so long as HSphere keeps group names the same as user names) | |
# bash doesn't have a group environment variable | |
chown $USER:$USER file | |
# if $item doesn't exist, make it | |
if [[ ! -d $item && ! -f $item ]]; then | |
echo "$item doesn't exist. Assuming directory." | |
mkdir -p $item | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment