Linux 普通用户sudo执行命令不需要密码

假设我这里的用户名是 hello

step 0: 切换到 root 用户:

su root

step 1: 设置文件权限

chmod 0777 /etc/sudoers

step 2: 修改文件

vim /etc/sudoers

在 #includedir /etc/sudoers.d 追加如下内容并保存退出:

hello    ALL=(ALL) NOPASSWD:ALL

注意:位置必须在#includedir /etc/sudoers.d 后面,添加在其他地方不生效

step 3: 设置文件权限

chmod 0440 /etc/sudoers

评论

暂无评论