I am running Ubuntu 12.04 on my laptop using VMware Player. I am not sure why but I have an account called "User Account" in addition to my account that I usually login to use Ubuntu. Well that was just a side comment but basically all I am trying to do is install the ncurses library on Ubuntu. I have tried installing ncurses using the following command lines:

sudo apt-get install libncurses5-dev
sudo apt-get install ncurses-dev

When I tried installing ncurses twice using the above commands I received the following prompt in the terminal:

[sudo] password for username

When I type in my password I receive the following message:

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

So far I have tried enabling the root user ("Super User") account by following these instructions.

Here are some of the things the link suggested to do:

Allow an other user to run sudo. Type the following in the command line:

sudo adduser username sudo


sudo adduser username sudo

logging in as another user. Type the following in the command line:

sudo -i -u username

Enabling the root account. Type the following in the command line:

sudo -i


sudo passwd root

I have tried all of the above command lines and after typing in each command I was prompted for my password. After I entered my password I received the same message as when I tried to install ncurses:

fsolano is not in the sudoers file. This incident will be reported.
  • I don't have comment's yet so bare with me here... Question. is fsolano the first user you made with the install of ubuntu? usually that should have admin privileges, if you perform an admin function in a graphical sense does it work for you at all? IE if you open the GUi for user management and try to do something adminy does it work? or tell you you aren't root
    – Gravy
    Commented Jan 19, 2015 at 23:14
  • 1
    Same question was asked here too ? superuser.com/questions/866582/…
    – shubham
    Commented Jan 20, 2015 at 1:37
  • if you've a root user with its password set , you can login root using su and add urself to sudo group àdduser username sudo else , you'll have to boot with live cd/usb and chroot to the installed system , it will log into root by default , set a root password for next cases passwd , and add yourself to sudo from there , and reboot , you'll have your username added to sudo and also you'll have root password , in case if sudo still not working , you can handle it ....
    – Yunus
    Commented Nov 6, 2015 at 13:21
  • 7
    – Fiksdal
    Commented Oct 16, 2016 at 14:05
  • I don't know if this is helpful but traditionally the group that is given sudo access is called "wheel". Get an account added to that group and they can usually use sudo. Maybe it's "sudo" in this case but that would be unusual so try wheel anyway if you can get root access or something. Usually the first account you created when installing your distro gets added to this group. So you may need to log into that account for access. Sudo itself has a lot of ways it can be configured so it's messages can be less than helpful.
    – davolfman
    Commented Mar 1, 2022 at 17:28

10 Answers 10


When this happened to me all I had to do to fix it was:

Step 1. Open a terminal window, CTRL+ALT+T on my system (Debian KDE after setting up as hotkey)

Step 2. Entered root using command su root

Step 3. Input root password

Step 4. Input command apt-get install sudo -y to install sudo

Step 5. Add user to sudoers file by inputting adduser username sudo, put your username in place of username

Step 6. Set the correct permissions for sudoers file by inputting chmod 0440 /etc/sudoers

Step 7. Type exit and hit Enter until you close your terminal window. Shutdown your system completely and reboot.

Step 8. Open another terminal window.

Step 9. Try any sudo command to check if your username is correctly added to sudoers file. I used sudo echo "Hello World!". If your username has been correctly added to the sudoers list then you will get Hello World! as the terminal response!

  • 22
    -1: cd - will not go to the home directory but to the most recent other directory. sudo - will not ask for your user password but for you root password. Do not edit /etc/sudoers manually use visudo for that. Typical ubuntu systems have no root password at all but rely completely on sudo.
    – michas
    Commented Apr 1, 2016 at 14:13
  • @michas You cannot use visudo without sudo in Debian. vi solution is also not possible because read-only. Gedit works in my case. Commented Jun 8, 2016 at 16:48
  • 1
    Why does visudo let me edit and save /etc/sudoers but doing vi /etc/sudoers doesn't? Commented Mar 1, 2019 at 5:30
  • 1
    Wow, I just had to do this with a brand new ubunu 22.04 install. Commented Apr 5, 2023 at 4:08
  • 2
    The steps described here DO NOT resolve the issue as described in the original question. Creating a user exclusively as a member of the sudo group might allow sudo but its bad practice.
    – symcbean
    Commented Jun 28, 2023 at 11:31

Follow the link to reset your admin password [sounds like you named your admin user account as user :)]

After that, login as the admin user and execute the following.

sudo usermod -aG sudo,adm fsolano

Now you can login as fsolano and you should be able to run sudo command.

If you get bash: usermod: command not found even as root, try:

/sbin/usermod -aG sudo,adm fsolano
  • 1
    Sorry I forgot to mention that I resolved this problem a very long time ago. This is the solution to the issue I had and possibly anyone else may have.
    – fsolano94
    Commented Jun 24, 2015 at 4:22
  • 3
    I still get the message after typing this as well as adduser NAME sudo. I think there m,ust be something else. I'm using Debian 7.8. Commented Oct 22, 2015 at 9:03
  • This is not sufficient solution in Debian 8.5. ShrikantKhawale's proposal with little additions is the correct here. Commented Jun 8, 2016 at 16:49
  • 3
    @masi The trick above does work in Debian 8.5 (at least here), but only after you log out and back in again.
    – jcoppens
    Commented Aug 12, 2016 at 17:36
  • @jcoppens is right, works for Debian 8.6 too, only after log out and login Commented Dec 30, 2016 at 17:05

I am having the same issue with Kali anytime I want to add newuser to the sudo group by typing this command:

usermod -aG sudo newuser

and editing the right section in /etc/sudoers. All crap!

My fix for this nonsense is to copy the line for root below it and changing root to newuser:

# User privilege specification
root    ALL=(ALL:ALL) ALL

newuser ALL=(ALL:ALL) ALL

I remember the usual method with usermod used to work but is it a bug for the last couple of years now? it's really nonsense. anyway, if someone has a better answer, share it please:)

  • Same issue on regular debian (9); manually editing /etc/sudoers did the trick
    – user149622
    Commented Jan 14, 2019 at 7:41
  • indeed, seems to be a bug. The user is in the sudo group. It was uncommented in /etc/sudoers - however, it didn't work! Only when i manually added as you suggested, it started to work. Thanks! Commented Nov 23, 2019 at 18:55

The config file /etc/sudoers list, who is allowed to run which commands as which user.

On ubuntu this file contains a line allowing all users of the sudo group to run commands as the root user.

To check which users are in the sudo group you can type getent group sudo. You can also check the groups of your current user by typing id.

Probably your current user is not in the sudo group and is therefore not allowed to use the sudo command.

Log in as some sudo enabled user if you want to run sudo.

  • Well thats just the thing. I would login as the admin or root user but I forgot the password when I first installed Ubuntu on my machine.
    – fsolano94
    Commented Jan 19, 2015 at 23:35
  • sudo:x:27:user (im not sure what the x or 27 is but I am positive that user is the user account that I do not know/remember the password to)
    – fsolano94
    Commented Jan 19, 2015 at 23:40
  • @fsolano94, boot into some form of rescue environment (either directly, or booting from installation media), and change the root password. Or edit the /etc/sudoers file (preferrably using visudo(1)).
    – vonbrand
    Commented Jan 4, 2016 at 16:27
  • that is the problem. login as another user solves nothing Commented Jul 10, 2020 at 8:59

Follow the instructions to reset the password for your admin user:

Then you'll be able to grant sudo permission to your regular user with

sudo adduser username sudo

as you posted in your original question.

By the way: why are you installing ncurses? Are you compiling something?

  • I am programming Tetris in C and am using curses as a cross platform for graphical user interfacing. And yup I am going to follow the link
    – fsolano94
    Commented Jan 20, 2015 at 0:04
  • is not in sudoers file... Commented Mar 15, 2021 at 3:37

You can also add a user to sudo group for all access right by:

  1. Going to your root directory user by sudo su (ubuntu 16.04 LTS)
  2. Then enter your current user password
  3. type sudo adduser <username> sudo where username is the name of the user you want to add in the sudoers list
  4. For checking if your required user is added succesfully type getent group sudo which will show the list of sudo users
  • 1
    Hi, welcome to Unix SE and congrats for a good first answer. I fixed your formatting a bit, you can learn more about that by clicking on "syntax help" when writing a post.
    – GnP
    Commented Sep 2, 2016 at 18:56
  • 2
    This is not a good answer. (1) The question states that sudo doesn’t work for the user.  (2) The answer sudo adduser <username> sudo has already been given. Commented Nov 30, 2017 at 16:22

If you have any other root/admin user than 'fsolano', that is not in the sudoers file. This incident will be reported:

check sudo enabled users (groups)
# getent group sudo 

since the user 'fsolano' is changed to standard user and if you have any other root privileged user, login via the root one and change 'fsolano' to administrator using "User Accounts".


Try the following command

su root -l -c "echo 'ismail ALL=(ALL)  ALL' >> /etc/sudoers"

However, I found a better solution.

su root -l -c "adduser ismail sudo"

replace ismail with your user name.

You have to restart the machine after running this command.


The simplest way to add an user to sudoers file is run the command bellow as user with permission to execute gpasswd:

sudo gpasswd -a username sudo

1.You can check whether you are a part of sudo group or not by using below command

groups username ===> it will lists the groups for which he belongs too

We can check by below script too

h=`groups username| awk -F ":" '{print $2}'| grep -io 'sudo'`
if [[ $h == "sudo" ]]
echo "user praveen is part of group sudo"
echo "Need to add user to group sudo"
echo "Swictch to root and add user"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .