Header Ads

Fix "Not in Sudoers file" Error in Linux

"Sudo" is a commonly used command in Linux. Two of the best advantages about using sudo are:
  • Restringed privileges
  • Logs of the actions done by users
But sometimes it you try to accomplish a task using Sudo command, you get an error message saying : " is not in Sudoers File". This can get quite frustrating as depicted in the pic. The file /etc/sudoers, has the rules that users have to follow when using sudo command, and this error arises when you user name is not in that file which restricts you to use that command. Here is a solution for the same.


(1) Open a Terminal window.
(2) Go to superuser by typing "su" and then entering the password for root user.
(3) Now type "visudo" to open the sudoers file.
(4) You will see a file more or less like this.
# /etc/sudoers## This file MUST be edited with the 'visudo' command as root.## See the man page for details on how to write a sudoers file.#Defaults        env_reset# Host alias specification# User alias specification# Cmnd alias specification# User privilege specificationroot    ALL=(ALL) ALL
(5) Navigate to the end of file and add the following line :


where "USER" is the username you use as standard user.

(6) Save and quit. This should solve the problem.