Reset a root password in Ubuntu

This issue was raised to me by my friend once and i didn’t paid a heed to this for like few years unless it so happened that I, myself forgot the admin password of my Ubuntu box and got wondering to to fix that. Here is a simple how to:

Boot up the machine, and after the BIOS screen, hold down the left Shift key (note that for UEFI BIOS you might need press ESC instead). You will then be prompted by a menu that looks something like this:

Go down hit the down arrow hey and select the recovery mode option.

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

root@ubuntu:~#

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

mount -o remount,rw /

Now we can set the user’s password with the passwd command. (In this example I will use akash as the example, you need to substitute whatever the user’s username is):

root@ubuntu:~# passwd akash
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ubuntu:~#

That’s it.
Enjoy!