When I go to terminal and try to enter a sudo commands it say's "Username not in the sudoers file." So how can I be able to use sudo commands.

  • 1
    Do you have any other users on the machine, or a password set for root? – Lewis Goddard Aug 2 '15 at 15:12
  • 2
    Can you login as root by entering your password using su - command? – r3bl Aug 2 '15 at 15:28
  • It asks for a password, I try mine but it won't work. – Jayeshwar Aug 2 '15 at 15:40

You need some user account with root priviledges to assign root priviledges to your own account.

To check if you have any such account on your computer you can either check:

a) Switchboard > User accounts

b) checking the content of sudoers file in /etc/sudoers. However I see no way of checking it without sudo other than booting from liveCD and opening it from there.

This is not exactly an answer and should have been a comment. However I don't have enough reputation points to comment your question so I've been forced to polute it with fake answer. Thanks for understanding.

  • I think this is probably fine as a partial answer :) Someone else could build off this to create a more complete answer – Daniel Foré Aug 2 '15 at 15:22
  • I do have another account with root privileges. So how do I assign it to my account. – Jayeshwar Aug 2 '15 at 15:25
  • you need to log into the other account with root priviledges and either do the change via switchboard (I don't know if it's possible as I have just one account) or opening terminal (WinKey+T) and entering 'sudo adduser <your_username> sudo' – jena Aug 2 '15 at 15:34

I ran into a similar issue as the only administator of my machine. If you have another administative user, jena's answer is an easier way.

I was really helped by an anwser on askubuntu about resting a lost administrative password. https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password

Full steps :

You need to boot into recovery mode.

Boot up the machine, and after the BIOS screen, hold down the left Shift key. You will then be prompted by a menu that looks something like this:

enter image description here

I've noticed on some systems that timing when to hit the left Shift key can be tricky, sometimes I miss it and need to try it again.

If you have full disk encryption, you have to hold down the key before being asked for the disk password. (You will be asked for the password in a command line interface during boot).

Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.

Now you should see this menu:

enter image description here

Using the arrow keys scroll down to root and then hit Enter.

You should now see a root prompt, something like this:


At this stage you should have a read-only filesystem. You have to remount it with write permissions:

mount -o rw,remount /

Now we can set the user back into the sudoers group with the adduser command. (In this example I will use jorge as the example, you need to substitute whatever the user's username is):

root@elementary:~# adduser jorge sudo

Now you can reboot, and you should be able to use sudo commands. You should make sure that you are part of following groups :

  • adm
  • sudo
  • lpadmin
  • sambashare
  • jorge (your username)

jorge@elementary:~$ groups

You can add your user back in these groups with sudo

jorge@elementary:~$ sudo adduser jorge adm


This can be achieved very easily by executing the following command in terminal

sudo usermod -aG sudo <username>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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