Bash-check-if-root-user: Difference between revisions
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...") |
mNo edit summary |
||
Line 1: | Line 1: | ||
<metadesc>bash function to see if the user running the script is the root user or not</metadesc> | |||
<pre> | <pre> | ||
got_root() { | got_root() { |
Revision as of 14:02, 25 April 2024
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 }