I am aware that I can prevent sudo command while I execute script; Suppose I have one test bash script and I don’t want that someone executes this script by issuing the following command:
username:~#sudo ./test
I implement one of following methods to prevent the above execution, I also implement one die method for that.
if [[ $UID = 0 ]] ; then
die "Please dont use sudo command with script"
fi
But i am not sure what I'm supposed to implement if root user themselves want to use the script. My above method will prevent root to use that script.
I am ok if root wants to execute script by this manner
root:~#./test