Bash: Check if user is root
Here’s a quick and easy way to ensure your script is running as root. I started using this with my server setup scripts at work to ensure they don’t fail somewhere through the script. # Check if root if [ "$(whoami)" != "root" ]; then echo “Not running as root, exiting…” echo “Please use sudo [...]














