这是我的根检查代码。如果不通过,请不要运行该脚本,因为您需要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