Bash-check-if-root-user
Jump to navigation
Jump to search
got_root() { if [ "$(id -u)" != "0" ]; then echo "Failure: This script must be run as root or sudo used"; exit 2 else echo "Confirmed: running as root, or sudo used" fi }
got_root() { if [ "$(id -u)" != "0" ]; then echo "Failure: This script must be run as root or sudo used"; exit 2 else echo "Confirmed: running as root, or sudo used" fi }