Require script to be run as root Start your bash script like this, ez pz. 1 2 3 4 5 #!/bin/sh if [ "$(id -u)" -ne 0 ]; then echo 'This script must be run by root' >&2 exit 1 fi #code #bash #zsh #unix #macos #root