Bash-check-if-root-user

From I Will Fear No Evil
Revision as of 15:02, 25 April 2024 by Chubbard (talk | contribs)
Jump to navigation Jump to search
got_root() {
if [ "$(id -u)" != "0" ]; then
  echo "Failure:  This script must be run as root or sudo used"; exit 2
else
  echo "Confirmed: running as root, or sudo used"
fi
}