My main username is not in the sudoers file
Solution 1
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:
-
nano
– CtrlO then Enter, then CtrlX to exit -
vim
–:wq
Solution 2
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
Solution 3
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
Related videos on Youtube
Braiam
Updated on September 18, 2022Comments
-
Braiam over 1 year
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 usingsudo
andsu username
but I got the same error!How I'm supposed to add my username to
sudoers
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.
-
Admin about 12 yearsThat 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.
-
Admin about 12 yearsTo boot into recovery mode, restart the PC and hold down the Shift button, then follow the instructions - psychocats.net/ubuntu/fixsudo
-
Admin about 12 yearsyou 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 about 12 yearsHis problem is in accessing a root terminal. And, you assumed that his editor is
nano
. Kindly improve it. -
Anwar about 12 yearsHow can he open a Root Terminal without giving root password which is not working?
-
jasmines about 12 yearsYou 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 tonano
.visudo
is included in standard Ubuntu installation. -
Fredrick Gauss about 10 years
Ctrl + K
thenX
worked. -
Andy K over 8 yearsMany thanks @monteirobrena. Your tip is very useful :)))
-
jmng over 6 yearsThis 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)