How To Tell If A Bash Script Was Called By Root
This snippet will detect if a bash script has been called by Root or not.
if test "`id -u`" -eq 0 then echo "Script was called by Root." else echo "Root did NOT call this script." fi
If all you want is to test if a bash script has not been called by Root, you can use the following.
if test "`id -u`" -ne 0 then echo "This script was not called by Root." fi
Available Wiki Topics
The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.