第一步:从普通用户转换到root用户
[lyl@localhost /]$ su
密码:
[root@localhost /]#
第二步:查看/etc/sudoers文件的权限
[root@localhost /]# ls -l /etc/sudoers
-r--r-----. 1 root root 4000 1月 15 2014 /etc/sudoers
如果如上图所示,是只读文件,将其更改为可写状态
[root@localhost /]# chmod 777 /etc/sudoers
[root@localhost /]# ls -l /etc/sudoers
-rwxrwxrwx. 1 root root 4000 1月 15 2014 /etc/sudoers
第三步添加内容到文件内
[root@localhost /]# vim /etc/sudoers
..
..
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
lyl ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
..
..
再将文件改为只读
[root@localhost /]# chmod 440 /etc/sudoers
[root@localhost /]# ls -l /etc/sudoers
-r--r-----. 1 root root 4019 1月 30 20:12 /etc/sudoers