#!/bin/bash # # simple script to determine if a user is root or not # and run a command w/ or w/o sudo as neccessary. if [[ "$EUID" = 0 ]] || [[ "`/bin/whoami`" = 'root' ]]; then echo "running $*" exec $* else echo "running sudo $*" exec sudo $* fi