User Tools

Site Tools


bash:check_whether_you_re_root

This is an old revision of the document!


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.1576615250.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki