Skip to content

Instantly share code, notes, and snippets.

@flickerfly
Created September 12, 2013 20:08
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 flickerfly/6543067 to your computer and use it in GitHub Desktop.
Save flickerfly/6543067 to your computer and use it in GitHub Desktop.
A little check if a script is being run as root and exit if not with an error.
# Must be run with root permissions
# sudo will be sufficient
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment