Created
January 24, 2019 22:32
-
-
Save unabridgedxcrpt/a4f2ec5c79c9ede1fce371cae3eefa07 to your computer and use it in GitHub Desktop.
Check if launched as root (or sudo)
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:-0} || "$(id -u)")); then | |
echo You are not root. | |
else | |
echo Hello, root. | |
fi | |
#Also: | |
# function amIRoot() { | |
# ! ((${EUID:-0} || "$(id -u)")) | |
# } | |
# | |
#from https://askubuntu.com/questions/15853/how-can-a-script-check-if-its-being-run-as-root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment