I was trying to install some software/edit files with my main username(not root) But I got this error [X] is not in the sudoers file. This incident will be reported.
I tried to edit the /etc/sudoers file by using sudo and su username but I got the same error!

How I'm supposed to add my username tosudoers file while I cant access it anyway?
I also tried to follow this guide here.

is the guide says, when booting 2 Operating systems(that's my case), then selecting Ubuntu, a menu will let you choose to start normally/open recovery mode/etc, but it's not happening for me, even if I hold shift no menu will pop up.

I installed Ubuntu by using Wubi and my Ubuntu version:12.04 LTS.

  • That guide looks pretty good for dealing with your sudo problem, and would probably work if you could follow it. I think you need to change your question to be "How can I boot into recovery mode?" and then ask about sudo if following that guide does not fix the problem. Jun 15, 2012 at 10:53
  • To boot into recovery mode, restart the PC and hold down the Shift button, then follow the instructions - psychocats.net/ubuntu/fixsudo
    – scouser73
    Jun 15, 2012 at 11:24
  • you will not get the Grub menu for a wubi install. If you have any other user account you can access, which has permissions to edit sudoers file, that may help. Else, you may have to use external tools for that. It certainly can be solved. :)
    – Mahesh
    Jun 15, 2012 at 11:30

4 Answers 4


Open a Root Terminal and type visudo (to access and edit the list).

Navigate to the bottom of the sudoers file that is now displayed in the terminal.

Just under the line that looks like the following:

    root ALL=(ALL) ALL

Add the following (replacing user with your actual username):

    user ALL=(ALL) ALL

Now save the file. The procedure for this will depend on your editor:

  • nanoCtrlO then Enter, then CtrlX to exit
  • vim:wq
  • 6
    His problem is in accessing a root terminal. And, you assumed that his editor is nano. Kindly improve it.
    – Mahesh
    Jun 15, 2012 at 11:31
  • 7
    How can he open a Root Terminal without giving root password which is not working?
    – Anwar
    Jun 15, 2012 at 11:50
  • 2
    You can easily find some online tutorial to retrieve/change your root password and you'll be able to open a standard terminal and give su to become root. Otherwise, you may want to boot with a Live CD and access the file after having mounted the HD. Finally, I wasn't referring to nano. visudo is included in standard Ubuntu installation.
    – jasmines
    Jun 15, 2012 at 12:03
  • Ctrl + K then X worked. Jun 5, 2014 at 14:45

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
  • Many thanks @monteirobrena. Your tip is very useful :)))
    – Andy K
    Jan 18, 2016 at 10:07

the process described at search: "psychocats ubuntu fixsudo" helped me on Lubuntu 13.04

Enter recovery mode then

mount -o rw,remount /

adduser username sudo
  • 1
    This is the easiest way I've encountered to solve this problem. For anyone wondering, you need to boot in recovery mode and choose "Drop to root shell prompt" to execute these commands (wiki.ubuntu.com/RecoveryMode)
    – jmng
    Nov 7, 2017 at 12:03

If you have the root password (may have been configured during installation), you can open a terminal and type su -l, then the root password. Lastly follow jasmines answer. To start edit in vim, go to the line below root ALL=(ALL) ALL and press i. I was able to follow these steps to add my account after an initial Fedora install.

Not the answer you're looking for? Browse other questions tagged or ask your own question.