新创建的用户,使用sudo切换到root时提示错误

1
xxx is not in the sudoers file.  This incident will be reported.

解决方法:

1
2
3
4
5
6
7
8
9
10
# 切换到`root`下
su
# 授权
chmod u+w /etc/sudoers
# 编辑sudoers文件
vi /etc/sudoers
# 添加
username ALL=(ALL) ALL
# 保存
chmod u-w /etc/sudoers