Bootstrap FreeKB - Bash (Scripting) - Run a BASH script as root
Bash (Scripting) - Run a BASH script as root

Updated:   |  Bash (Scripting) articles

The following markup in a BASH script can be used to ensure that the script is being run as root. Credit goes to this post on Ask Ubuntu for this markup.

#!/bin/bash
if [[ $EUID -ne 0 ]]; 
then
   echo "This script must be run as root" 
   exit 1
fi

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c79179 in the box below so that we can be sure you are a human.