Monday, March 16, 2009

Restoring your Ubuntu password

As you probably already know, Ubuntu does not allow you to login as root onto the system.
Any action that need root privileges needs to be run using the "sudo" utility
For ex: sudo command
Situation 1:
You have a dual-boot system with Ubuntu and Windows and haven't logged onto the system for a while and you forgot the login password for the Ubuntu installation

Situation 2:
You have installed Ubuntu as a VM and have not booted the system for a while and you forgot the login password for the Ubuntu installation

What would you do now? Re-install the OS?
Here is a very simple solution!

Boot up the Ubuntu installation..and
Press the ESC key immediately to see a Menu that would show the different installations available on the system
Select the option as shown in the image on the right here:
The option shows a "recovery mode" in the brackets.


P.S. Though the snapshots are from a Ubuntu server boot-up , the same will apply to Ubuntu Desktop editions too.

The system boots up and shows the prompt shown below:


{
NOTE : Anything that happens after here has to be done very carefully and exactly as listed below. 'Coz, you'll be root and root can do ANYTHING! Including wiping your hard disk clean if wrong commands are used. You've been warned.
}

Select the option "root Drop to root shell prompt" and this will bring you to a shell prompt with root privileges
Now, if you remember the user, you could simply do a

passwd username

and re-set the password of the user.

But, if you do not remember the username also, run the command


cat /etc/passwd

and this will list all the users on the system; may be the list will make you remember the user that was created as the "sudo" user.

You should be able to login at the UI prompt, after the password has been re-set.
Now run the command,

reboot

and let the system boot normally

If you still have problems logging into the system, leave me a comment with your e-mail id, I'll contact you!

No comments: