Last active
March 1, 2019 22:47
-
-
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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