Check to see if a script was run as root
Apr 16, 2008 By Mitch Frazier
If you need to make sure a script is run as root, add the following to the start of the script:
if [[ $UID -ne 0 ]]; then echo "$0 must be run as root" exit 1 fi
Mitch Frazier is an Associate Editor for Linux Journal.
- Understanding OpenStack's Success
- Ensono M.O.
- Own Your DNS Data
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- From vs. to + for Microsoft and Linux
- Bash Shell Script: Building a Better March Madness Bracket
- The Weather Outside Is Frightful (Or Is It?)
- Natalie Rusk's Scratch Coding Cards (No Starch Press)