I\'m writing a script that requires root level permissions, and I want to make it so that if the script is not run as root, it simply echoes \"Please run as root.\" and exit
try the following code:
if [ "$(id -u)" != "0" ]; then echo "Sorry, you are not root." exit 1 fi
OR
if [ `id -u` != "0" ]; then echo "Sorry, you are not root." exit 1 fi