这是我的根检查代码。如果没有通过,请不要运行脚本,因为您需要 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
[root@localhost ~]# whoami
root
[root@localhost ~]# id -un
root