[Shell Tips] 檢查是否有 root 權限

if [[ $EUID != 0 ]]; then
    echo -e "[\e[0;35m warn \x1B[0m] This script requires root privileges"
    sudo "$0" "$@"
    exit $?
fi

參考來源: Armbian

This entry was posted in shell script and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *