Ubuntu Tutorial: Recover password

0 - Introduction

Losing your password nowadays can be catastrophic, glady there is a way to recover it on Ubuntu.

But firstly you need access to the physical machine (in case of a virtual machine you don’t need ‘physical access’ of course) as we will use grub to boot into recovery mode.

1 - Recovery

If you have your machine dual-booting ubuntu and any other operating system, like windows, you probably already know what grub is, it’s the menu that let’s you choose which operating system to boot into, but in the chance that you have only one os, you can just spam the left SHIFT key while the pc is turning on.

Don’t worry if you don’t hit it at first, it can be very hard to get the timing! Just restart your pc and try again.

Once you get to this menu select ‘Advanced options for Ubuntu’

Once in here you might have more than two options. It is common to have even four. Just select the first that says ‘(recovery mode)’ as it is usually the most recent version of the linux kernel.

In the recovery menu you might notice that the ‘filesystem state’ is ‘read-only’, we have to change it, and we do that by going to ‘fsck’ and pressing ‘yes’ when prompted.

You will then go back to the same menu, but now you press ‘root’. That will show ‘Press Enter for maintenance’, press enter, and then you will have access to a root console!

In here you need to write:

passwd yourusername

You can then input a new password and you are done! Now reboot your machine and login with the new password.

If you don’t know your username use this command to find all users:

ls /home

Now you should be able to reset your password in case of an emergency! But you might be wondering, isn’t this a security risk? Not really, because if an attacker has physical access to your machine they could do worse things with, for example, a boot CD.

Thanks for reading and stay tuned for more tech insights and tutorials. Until next time, and keep exploring the world of tech!