我使用的是centos7.5,切换到root用户执行
1、修改/etc/sudoers文件权限,默认只读,给属主添加写入权限:
[root@node1 ~]# chmod u+w /etc/sudoers
2、编辑/etc/sudoers文件
[root@node1 ~]# vi /etc/sudoers
向其中加入以下红色部分:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
puser ALL=(ALL) NOPASSWD:ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
其中puser为需要添加sudo权限的用户名称,此处设置为不需要密码验证。
网友评论