1. 问题描述
centos或ubuntu下, 新增了用户, 用户名为xx,
则以sudo(以管理员身份)执行命令时, 出现以下提示
xx is not in the sudoers file. This incident will be reported.
译
xx 不在 sudoers 文件中。此事将被报告。
下面将添加用户xx到sudoers文件中
2. 切换到管理员
# su -
密码:
# vim /etc/sudoers
## 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
xx ALL=(ALL) ALL # 新增条目, xx为用户名
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Allows members of the users group to mount and unmount the
## cdrom as root
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
:wq!
最后强行保存退出
3. 测试sudo
如
$ sudo mkdir test
没消息即好消息!最好检验下是否成功
# ls -l