這是我的根檢查代碼。如果不通過,請不要運行該腳本,因爲您需要root用戶。不知道以什麼錯誤的位置:腳本無法以根用戶身份運行
if [ "whoami &2>/dev/null" != "root" ] && [ "id -un &2>/dev/null" != "root" ] ; then
$BIN_ECHO " must be root to run this script "
exit 1
else
$BIN_ECHO -e " permission check passed "
fi
運行後,我得到:
must be root to run this script
[[email protected] ~]# whoami
root
[[email protected] ~]# id -un
root