Bash require run as root

Require a bash script to run with root permissions.

#!/bin/bash
 
if [[ "${EUID}" != 0 ]]; then
   echo "Script must be run as root. Try: sudo bash ${0}"
   exit 1
fi
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment