From charlesreid1

Revision as of 21:28, 9 September 2018 by Admin (talk | contribs) (Created page with "==patterns== ===check if root user=== Use <code>$(id -u)</code> to get the UID. the UID will be 0 if the user is root. <pre> if [ "$(id -u)" != "0" ]; then echo ""...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

patterns

check if root user

Use $(id -u) to get the UID. the UID will be 0 if the user is root.

if [ "$(id -u)" != "0" ]; then
    echo ""
    echo ""
    echo "This script should be run as root."
    echo ""
    echo ""
    exit 1;
fi