Tuesday, March 10, 2015

Check the bash shell script is being run by root or not

#!/bin/sh

# Make sure only root can run this script
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

No comments: