Fix Error Username is not in the sudoers file – This incident will be reported

In Unix/Linux systems, the root user account is the super user account, and it can therefore be used to do anything and everything achievable on the system. But the root user account is locked by default, regular users (system administrators or not) can only gain super user privileges by using the sudo command.

However, In the case, the issue is caused by your user not having sudo access in your system.

Below is an image showing a case in which the default system user is being prevented from running sudo command:


In this tutorial, We will learn How to Fix Error Username is not in the sudoers file – This incident will be reported in Linux

Step 1 – Get information about user currently logged in your system

  • First, find what is your username by run the command below :


  • As a result like such as: [ My username : hg ]

Step 2 – Switch to mode root user

  • To switch user to root using the command below:


  • And input password of root user

Step 3 – Fix Error

  • Open and Edit /etc/sudoers file by follow command below:

sudo vim /etc/sudoers


sudo vi /etc/sudoers

  • Find line “root ALL=(ALL) ALL” and add the following line below it. Replace %username% with your user name in step 1

%username% ALL=(ALL) ALL

Example: hg ALL=(ALL) ALL

  • Save and exit file by press Esc Shift :x! Enter

Finally, Restart the system for the change to take effect

Thank you for reading !!!


Leave a Reply

Your email address will not be published. Required fields are marked *