Skip to content

Instantly share code, notes, and snippets.

@malias
Last active December 21, 2015 19:18
Show Gist options
  • Save malias/d7c1f3146023163f11bd to your computer and use it in GitHub Desktop.
Save malias/d7c1f3146023163f11bd to your computer and use it in GitHub Desktop.
With this script, u can change permissions with a default value (files=644 & directories=755). Change the path to ur directory and start the script from ur console or cronjob
#!/bin/bash
#
#
## Der PATH muss angepasst werden
## Für die Webseite kann z.b. /home/[BENUTZERNAME]/public_html/
## Bsp: Path='/home/oliveror/public_html/'
Path='/home/[BENUTZERNAME]/[PFAD]/'
function setChmod {
ls -1 "$1" | while read file
do
file="${1}/${file}"
if [[ -f "$file" ]] && [[ `stat -c %a "$file"` != 644 ]]
then
chmod -v 644 "$file"
elif [[ -d "$file" ]]
then
chmod -v 755 "$file"
setChmod "$file"
fi
done
}
setChmod $Path
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment