Recovering lost password in Ubuntu 12.04

Yesterday, While I was trying to help my friend with his lost Ubuntu password, I explored the following two methods to do this quite easily.

First method is using the recovery mode. This method is pretty simple.

In the grub menu, select the recovery mode. Then in the menu that appear, scroll down to the option ‘Drop to root shell prompt’. Now you will get a shell prompt with root authentication at the bottom of the screen. Now before changing the password we have to remount the root in read write mode and for that run the following command.

            mount -rw -o remount /

Now go ahead and change the password of the corresponding user using the following command.

            passwd <username>

Now the prompt will ask for the new password. After entering it twice, as will be asked by the prompt, exit from the prompt by just entering exit. Now select the resume normal booting option. Sometimes when booting into the system from recovery mode can give you a disoriented display screen and simple restarting is the solution for this.

Although the above method worked just fine in my system, my friend didn’t have much luck in making this work in his system ( God knows why. ). So I tried another method and that is using the live CD. The steps I followed are as follow :

1. Boot into the Ubuntu live CD and select the option try Ubuntu.

2. Open  the terminal and mount the partition that is the root partition for your actual Ubuntu as mount point.

  • If you don’t know the root partition, open gparted and see which drive is set as bootable.

Suppose /dev/sda1 is your root partition. Now to mount it as the mount point run the command :

   sudo mount /dev/sda1 /mnt

3. Make this mount point as root and for this we use chroot :

sudo chroot /mnt

4. Now you can proceed with changing password of the corresponding user, i.e. :

  sudo passwd <username>

Enter the new password as asked.

5. Un-mount the root partition

umount /mnt

6. Restart the system and now you can log in to your system with the new password.

I found some more methods too, online, but the above two worked perfectly for me. So didn’t bother to experiment with anything else. Hope this works for my friend too.


9 thoughts on “Recovering lost password in Ubuntu 12.04

  1. I haven’t been in this disaster yet, but yes, it may pop up any day. However, I am not sure the first approach would work if you have your root password set and have forgotten that too. I think you were able to do it because you did not have your root account created (In Ubuntu, root is not created by default. So you use “sudo” for admin tasks).

    However, Linux (or Grub rather) has this security vulnerability wherein you can do a small edit to the Grub menu entry and enter into your account as root without password or anything. I do not remember how it was, but I was the center of being criticized at college for a few days when my friends found out about this.

    Will try to recollect what it was and post it here.

    • That would be really helpful. I wasn’t aware of this. I bet this’s the reason why the first method didn’t work out for my friend and I don’t even know which distro he’s using.

  2. I have been using ubuntu 12.04 since November 2013. In fact I didn’t forget my password but still couldn’t log in using my root password.
    I tried all methods available on the Internet but in vain.:(

    • Did you get the problem cleared?

      Are you using your root account password to log in as root or user? Use your username and user password to log in.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s