Skip to content

Instantly share code, notes, and snippets.

@zealfire
Created July 8, 2017 19:01
Show Gist options
  • Save zealfire/d1d81149a30905986eeb9f6729f41d05 to your computer and use it in GitHub Desktop.
Save zealfire/d1d81149a30905986eeb9f6729f41d05 to your computer and use it in GitHub Desktop.
Test if you are root, and if not, restart with sudo, for example:
#! /bin/bash
if [[ $EUID -ne 0 ]];
then
exec sudo /bin/bash "$0" "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment