Skip to content

Instantly share code, notes, and snippets.

@Gisleburt
Last active December 15, 2015 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gisleburt/5204512 to your computer and use it in GitHub Desktop.
Save Gisleburt/5204512 to your computer and use it in GitHub Desktop.
Many Linux problems are caused by messed up permissions. This fixes that shit (sort of).
#!/bin/bash
# This bit is by Brian Campbell
# Source: http://stackoverflow.com/questions/699576/validating-parameters-to-a-bash-script
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "This shit takes one arguement user[:group]"
# This bit is mine
# http://www.danielmason.com
sudo echo "Fixing this shit" && \
sudo echo "Fixing ownership" && \
sudo chown -R $1 . && \
sudo echo "Fixing permissions" && \
sudo chmod -R o-rwx . && \
sudo chmod -R ug+rwX . && \
sudo echo "This shit is fixed"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment