User Tools

Site Tools


bash:check_whether_you_re_root

BASH - Check Whether You’re Root

#!/bin/bash
ROOT_UID=0
 
if [ "$UID" -eq "$ROOT_UID" ]
then
echo "You are root."
else
echo "You are not root"
fi
exit 0

The output of this script depends on the user running it.

It will match the root user based on the $UID.

bash/check_whether_you_re_root.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki