Ensure that a script is executed as root
#!/bin/bash if [[ "$(id -u)" -ne 0 ]]; then sudo "$0" "$@" exit $? fi