3

I need to use sudo but when I try to use it, a prompt tells me the command is not found and I need to install sudo.
So when I switch to su so I can gain root access to install sudo, it says auth failure

sudo and su problem description

How can I fix this?

  • 3
    You might need to enter the recovery mode at the Grub menu, select the 'root shell', and try installing sudo. Not sure will work though. Obviously, sudo is preinstalled by default, and removing it was a bad idea. – mikewhatever Mar 1 at 11:26
  • It's ironic how it suggests to use sudo to install sudo. Even more ironic that it would probably suggest the same thing again if you actually typed the command it had suggested to you. – kasperd Mar 2 at 10:41
12

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:

Grub Menu

If instead you get options like: Initial Grub Menu

You need to go to Advanced Options using arrow keys and hit Enter and then choose the recovery mode

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: Recovery mode

Using the arrow keys scroll down to network and hit Enter to enable networking. If asked to remount the partition, hit Enter on yes.

And then go to root in the same menu and then hit Enter.

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

root@gijs-pc:~#

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

mount -o remount,rw /

now, install sudo by:

apt install sudo

check your sudo settings once again by:

visudo

also, check if your account gijs is a member of sudo If not, add him as a member of sudo and wheel group by:

usermod -aG sudo gijs
usermod -aG wheel gijs

Now, you may restart and you now should have access to sudo.

This answer is abridged version of Jorge Castro's answer on How do I reset a lost administrative password?

  • 2
    Maybe you should enable network before dropping to root shell !! – Soren A Mar 1 at 11:50
  • 1
    Hmm.. Indeed as @Olorin said, It is a duplicate. Surely, we can use pkexec too – Varun Chhangani Mar 1 at 12:25

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