Skip to content

Instantly share code, notes, and snippets.

@kodekracker
Created November 26, 2014 17:25
Show Gist options
  • Save kodekracker/a55aff7a6f47b42dddff to your computer and use it in GitHub Desktop.
Save kodekracker/a55aff7a6f47b42dddff to your computer and use it in GitHub Desktop.
How to check a script file is being run as root
#!/bin/bash
# Author : Akshay Pratap Singh
# Email-id : pratapakshay0@gmail.com
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment