This will force your user that runs the bash script to run as root, if they are now root it will exit and not let them continue to run the script. This can be useful in many situations when writing bash scripts.
if [[ ! $(whoami) = "root" ]]; then echo "Please run the script as root." exit 1 fi
0 comments:
Post a Comment