Created
May 8, 2023 22:49
-
-
Save frederikheld/76199f69b482400426b6121ccc01defe to your computer and use it in GitHub Desktop.
Make sure that script is being run as sudo
This file contains hidden or 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/sh | |
if [ "$(id -u)" -ne 0 ] | |
then | |
echo "This scripts needs elevated privileges. Please run as sudo!" | |
echo "Correct usage:" | |
echo " $ sudo sh $(basename "$0")" | |
exit 1 | |
fi | |
echo "Hello Sudo!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this comment on why this might not be the best way to go: https://unix.stackexchange.com/a/353207/320012