Skip to content

Instantly share code, notes, and snippets.

@semihcosu
Last active April 25, 2018 21:49
Show Gist options
  • Save semihcosu/f7ce5c05a62011187bf4354d66cff17d to your computer and use it in GitHub Desktop.
Save semihcosu/f7ce5c05a62011187bf4354d66cff17d to your computer and use it in GitHub Desktop.
Fix webhost permissions
#!/bin/bash
owner=$(whoami | awk '{print $1}')
if [ "$(whoami)" == 'root' ]; then
echo $"You shouldn't be running this as root."
exit 1;
fi
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
sudo chown -R $owner:www-data .
echo $"Great! Now you have the permissions you need. Hope you're happy now."
@semihcosu
Copy link
Author

Usage:
Switch to the directory with
cd ~/project

And run webhost_permissions without sudo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment