I'm writing a simple bash script, but I need it to check whether it's being run as root or not. I know there's probably a very simple way to do that, but I have no idea how. Just to be clear: What's a simple way to write a script foo.sh , so that the command ./foo.sh outputs 0 , and the command sudo ./foo.sh outputs 1 ?
Originally asked by Malabarba on Stack Exchange (askubuntu) (CC BY-SA 2.5).