Created
October 21, 2018 19:44
-
-
Save markhilton/f888c0b14306b38bfcd633e56a86713f to your computer and use it in GitHub Desktop.
Set recursively default directories (755) & files (644) privileges. Usage: fix_privileges.sh $path
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
#!/bin/bash | |
die () { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 1 ] || die "ERROR: path argument is required, $# provided" | |
if [[ ! -d "$1" ]]; then | |
echo "ERROR: specified path is not a valid directory" | |
exit 1 | |
fi | |
# To change all the directories to 755 (drwxr-xr-x): | |
find $1 -type d -exec chmod 755 {} \; | |
# To change all the files to 644 (-rw-r--r--): | |
find $1 -type f -exec chmod 644 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment