I just need a code fragment with checks if the user is the root user.
Basically I need to ensure it was run as "sudo myscript" rather then just "myscript"
if [ "$USER" != "root" ]; then
echo "You are not root user, please log in as root user"
But that didn't work. I thought maybe it was because I had not defined the variable $USER and I wasn't sure how to.
Any help will be appreciated.