Archive for the ‘Linux’ Category

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 [...]

Posted on July 22, 2010 at 5:10 pm by Brad · Permalink · Leave a comment
In: Bash, Linux · Tagged with: ,