1.切换到root用户

[TZ@localhost 桌面]$ su -

密码:

[root@localhost ~]# ll /etc/sudoers

-r--r-----. 1 root root 4038 6  29 10:17 /etc/sudoers

2.修改/etc/suoders权限为可写

[root@localhost ~]# chmod 777 /etc/sudoers

查看文件权限,颜色变为绿色

[root@localhost ~]# ls -l /etc/sudoers

-rwxrwxrwx. 1 root root 4038 6  29 10:17 /etc/sudoers

3.编辑修改/etc/sudoers文件

[root@localhost ~]# gedit /etc/sudoers

TZ    ALL=(ALL)     NOPASSWD: ALL

4.保存退出并恢复/etc/sudoers的访问权限为440

[root@localhost ~]# chmod 440 /etc/sudoers

[root@localhost ~]# ls -l /etc/sudoers

-r--r-----. 1 root root 4038 6  29 10:17 /etc/sudoers

5.然后重启即可