32

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.

Braiam
  • 69,112
Aziz
  • 323

4 Answers4

49

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
wchargin
  • 178
jasmines
  • 11,311
7

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
4

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
user194498
  • 41
  • 1
0

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.

Qwexer
  • 101