Bash: Run entire shell script as root
Placing sudo in the shebang line of a shell script runs the entire thing as root. Useful for scripts designed to, e.g., automate system upgrades or package manager wrappers - makes prepending everything with sudo no longer necessary.
#!/usr/bin/sudo /usr/bin/env bash
Via commandlinefu.com.
Leave a comment