为了安全及管理的方便,可将需要root权限的普通用户加入sudo管理,这样用户就可以通过自己的普通用户登录,利用root的权限来管理系统了,也不需要有root账号和密码了。

对外只开放80及443端口


visudo命令打开sudo的配置文件进行编辑。

root ALL=(ALL) ALL

nn ALL=(ALL)   /usr/sbin/useradd,/usr/sbin/userdel

xc ALL=(ALL)   NOPASSWD:ALL


检查grep xc /etc/sudoers


方法二

cp /etc/sudoers /etc/sudoers.ori

echo "nn ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers

tail -1 /etc/sudoers

visudo -c #语法检查


sudo ls /root

sudo su - 切换root

sudo -l 查看权限


cd无法用subo