To use sudo, you need to be registered in the “/etc/sudoers” because this file determines if the user has permission to execute any task. However, many users face some unusual errors while using the “sudo” command.
In this quick tutorial, we will explain the different approaches that you can use to resolve the “Is not in the sudoers file. This incident will be reported” error easily.
How to Resolve the “Is Not in the Sudoers File. This Incident Will Be Reported” Error
The straightway fix to this error is modifying the “/etc/sudoers” file. This simple process requires the root user to add the user (who is facing this error) in the sudoers file.
You can use the “Visudo” command to directly open the “/etc/sudoers” file. Visudo is a special command that is purposefully made to modify the sudoers file.
Navigate to the line that says “root ALL=(ALL:ALL) ALL” and enter the following text in the next line:
Ensure that you replace the term “user_name” with the actual name of the user to whom you want to provide the sudo privileges.
After changing everything, you can now save and exit the file. Finally, you now completed the process and the “is not in the sudoers file” error will no longer bother you. The upcoming section will discuss a one-line command that you can use to add the users to the sudo group which contains the sudo privileges by default.
The Sudo Group
Instead of adding the user like what is demonstrated in the previous process, you can add the intended user to the sudo group. When added to this group, the user will get the sudo access. Hence, this will aid you in resolving the error.
To do this, enter the following given command in the terminal:
The “usermod” command with the “-aG” options and input sudo adds the specified user to the group– sudo. Furthermore, replace “user_name” with the target user’s username/user ID.
Conclusion
The said error usually shows that the user is not currently available in the sudoers file. Its only resolution is to add the affected user to the mentioned file. In this article, we explained two ways: modifying the sudoers file and adding the user to the sudo group. You can use any of the two to get rid of this error.