8

I accidentally deleted the /usr/bin/sudo file. How can I restore it?

I have found a thread on ubuntuforums, but it seems to be not solved.

7

The reason I write this instruction here is that I didn't find a step-by-step solution when I ran into the problem myself. I'm a Linux newbie myself, so feel free to edit this :)

These steps solved the problem for me:

Boot into recovery mode (press Esc or left Shift after BIOS splash) enter image description here

Select Drop to root shell prompt option enter image description here

Mount the file system in writable mode:

mount -o rw,remount /

Add the internet connection (I'm not sure if this works with Wi-Fi):

dhclient eth0

Now you have to purge the existing sudo package. It's protected against removal, so you have to set this environment variable:

export SUDO_FORCE_REMOVE=yes

Purge the sudo:

apt-get purge sudo

That command also purged the ubuntu-minimal package, so if we run

apt-get install ubuntu-minimal

this will restore both packages

Reboot the system:

reboot

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