How-To Geek
Reset Your Ubuntu Password Easily from the Live CD
Our last article on how to reset your Ubuntu password easily through the grub menu was quite popular, so I’ve decided to make a series on all the different ways to reset your password on either Linux or Windows… today’s lesson is how to use the Live CD to reset the password.
Note that we’ll also cover how to protect yourself against somebody else resetting your password, so stay tuned!

Of course, this method will also work if you’ve installed your Ubuntu Live CD to a thumb drive.
Resetting the Password
You’ll want to boot from your Ubuntu Live CD, choosing “Try Ubuntu without any change to your computer” from the boot menu.

Once the system boots, open up a new Terminal window from Applications \ Accessories and then type in the following command:
sudo fdisk -l
This command is used to tell what device name the hard drive is using, which in most cases should be /dev/sda1, but could be different on your system.

Now you’ll need to create a directory to mount the hard drive on. Since we’re actually booting off the live cd, the directory doesn’t really get created anywhere.
sudo mkdir /media/sda1
The next command will mount the hard drive in the /media/sda1 folder.
sudo mount /dev/sda1 /media/sda1
Now it’s time for the command that actually does the magic: chroot. This command is used to open up a shell with a different root directory than the current shell is using, and we’ll pass in the folder where we mounted the hard drive.
sudo chroot /media/sda1
Now you should be able to use the passwd command to change your user account’s password, and it will be applied to the hard drive since we are using chroot.
passwd geek
Note that you’ll have to type your username after the passwd command in order to change the right password.

Now you should be able to reboot your system and log yourself in with your new password.
Got Feedback? Join the discussion at discuss.howtogeek.com
Comments (30)
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 09/25/08




I have only disk with vista loaded.
suppose if forget the password then will this method work for resetting the vista passwd ??
abhi
This article has nothing to do with Vista.
For resetting the passwords on Windows you can use the Ophcrack LiveCD. I used to it reset the password on my parents XP computer. While not positive, I think it works for most versions of Vista. Be responsible with it!
Great article, I just put a dual-boot Ubuntu on a 1GB Vista laptop rather than spend £30 on another GB of memory. I’d be a total convert if I didn’t have to use Windows for work. This kind of information is just one of those `need to know` things that is bound to come in useful.
Re: the previous comment(s) there is a specific version of Ophcrack for Vista. It manages passwords a little differently to 2000/XP (much much harder to crack if you have a complex password apparently).
To the post above brundle, VMware works in Ubuntu very very well. You should probably give that a shot.
What if you don’t know the user name?
Awesome, hopefully it works. Thanks and GOD Bless you all.
Thank you. I used this technique after I “passwd -l”ed all my users on accident.
If you don’t know the username, you can use this command to display all the users:
cat /etc/passwd
You can save that passwd file in case you need to change it back? I seem to remember in Unix systems the passwd file being all you need to get to crack passwords. Well at least 15 years ago since they’ve maybe gotten too hard to crack that way. Heh. Either way, returning the line in the passwd file should restore it in case you remember it again?
I know that some computers are setup so that changing the password without going through a special tool will corrupt encrypted files/folders/drives. The tool creates a chain of old password hashes I’d (maybe naively) imagine. Corrupt as in remove access to them. :/ This is the one BIG caveat of using password reset disks on Windows with folder encryption for example.
This works like a champ! I couldn’t get into Ubuntu 9.10 and booting to the live CD and running these instructions fixed it. THANKS!!
Worked perfectly the first time. Thanks so much!
I’ve installed Ubuntu 10.04 currently running in VirtualBox and forgot my password. This worked perfectly!
Thank you very much!
thats’s best way .
thanks.
Worked great! Thanks.
How can i install VM on my Windows 7 Premium Edition? I would like to Install Ubuntu on a virtual machine.
I tried it and it everytime i tried to mount it it wouldn;t let me do it, it said something about the etc/bin or something similar
Some people are idiots. lol
I have a digital door lock that takes a password.
first, how to i mount the door, and two, will this reset my home security password?
lol get real windows users
thank u soooooooooooo much!!!! thank u thank u. it worked for me.
OMG I Love You :)
Straight to the point help like this is what I’d like to find without wasting hours the next time.
I may be missing the point but is this article over complicating things? If a password reset is required on a Linux installation then choose the recovery mode option from GRUB. From the recovery menu go to a command prompt and then use “passwd username” to reset the password of the required “username”.
This avoids the need for live CDs or a CHROOT environment.
Regards
Mark
Just did this for a client that had 4 machines (Compaq desktops) – 2 differing versions 9.4 & 10.1
All had issues where GRUB esc and shift keys did not work.
The grub timeout was set to 0 and I do not think the USB keyboards were “operational yet” Some or other BIOS issue.
Used the 9.4 boot CD – this method. Worked Very easily. Even had to “fix a disk” not wanting to mount properly.
Thank you .. Have become a follower!!!
Commands were going smoothly until I reached this command:
sudo chroot /media/sda1
and I get the error:
chroot: failed to run command ‘ /bin/bash’: No such file or directory.
Googled around that error, but no solution when booting from a live cd?
Thanks.
WEWA, sda1 is the primary partition. If you installed to a different partition (like I did to dualboot Windows and Ubuntu) you will need to substitute the partition you installed Ubuntu on in place of sda1. For me it was /dev/sda5.
Um, help? I used this guide when editing the grub file and using recovery mode failed me, and it worked… but now I get a pop-up asking me for the ‘Unlock Login Keyring’ every time I try and do something. Does anyone know how to fix this?
You made it clear and easy.
Thank you.
:)
worked like a dream with no glitches thanx a lot
Many many thanks, this fixed my problem without fuss. Just goes to show that a default (most) Linux default desktop setups can be cracked into in the same way as Windows ones can.
I’m having Kubuntu running on my machine.
I tried this but it says “chroot: cannot run command `/bin/bash’: No such file or directory”
What do i do….???
Plzz help me… asap
I was tired when I changed the password on one of my Linux computers. When I woke up in the morning I couldn’t remember it. Didn’t have much important stuff so I just reinstalled. It’s free. lol.
Much quieter than a big hammer. When it comes to the command line it takes me so long I just call my friendly Linux geek. Also much quieter because he can only curse in one language.
Have fun.