Bash-check-if-root-user: Difference between revisions

From I Will Fear No Evil
Jump to navigation Jump to search
(Created page with "<pre> 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...")
(No difference)

Revision as of 16:18, 15 October 2021

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
}