Skip to content

Instantly share code, notes, and snippets.

@ccarrasc
Last active March 1, 2019 22:47
Show Gist options
  • Save ccarrasc/5813828 to your computer and use it in GitHub Desktop.
Save ccarrasc/5813828 to your computer and use it in GitHub Desktop.
Verify a script is being executed as root. The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0:
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment