CentOS7 'Username' is not in the sudoers file. This incident will be reported

新装的 CentOS 需要安装许多软件,但是如果一开始你不是以 root 登入的话,就需要使用 sudo 进行切换,但是通常会报错如下图:

CentOS7 'Username' is not in the sudoers file. This incident will be reported

解决方法:

先用 root 用户登入系统,

打开文件

vi /etc/sudoers

将用户名称添加到文件中
user_name ALL=(ALL)  ALL