Subscribe to How-To Geek

Reset Your Forgotten Ubuntu Password in 2 Minutes or Less

If you've ever forgotten your password, you aren't alone… it's probably one of the most common tech support problems I've encountered over the years. Luckily if you are using Ubuntu they made it incredibly easy to reset your password.

image 

All it takes is adjusting the boot parameters slightly and typing a command or two, but we'll walk you through it.

Reset Your Ubuntu Password

Reboot your computer, and then as soon as you see the GRUB Loading screen, make sure to hit the ESC key so that you can get to the menu.

image

Root Shell - Easy Method

If you have the option, you can choose the "recovery mode" item on the menu, usually found right below your default kernel option.

image[3]

Then choose "Drop to root shell prompt" from this menu.

image[6]

This should give you a root shell prompt.

Alternate Root Shell Method 

If you don't have the recovery mode option, this is the alternate way to manually edit the grub options to allow for a root shell.

First you'll want to make sure to choose the regular boot kernel that you use (typically just the default one), and then use the "e" key to choose to edit that boot option.

image 

Now just hit the down arrow key over to the "kernel" option, and then use the "e" key to switch to edit mode for the kernel option.

image

You'll first be presented with a screen that looks very similar to this one:

image

You'll want to remove the "ro quiet splash" part with the backspace key, and then add this onto the end:

rw init=/bin/bash

image 

Once you hit enter after adjusting the kernel line, you'll need to use the B key to choose to boot with that option.

image 

At this point the system should boot up very quickly to a command prompt.

Changing the Actual Password

You can use the following command to reset your password:

passwd <username>

For example my username being geek I used this command:

passwd geek

image

After changing your password, use the following commands to reboot your system. (The sync command makes sure to write out data to the disk before rebooting)

sync
reboot –f

I found that the –f parameter was necessary to get the reboot command to work for some reason. You could always hardware reset instead, but make sure to use the sync command first.

And now you should be able to login without any issues.

The Geek is the founder of How-To Geek and a geek enthusiast. This article was written on 09/22/08 and tagged with: Linux

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your email below:


Comments (18)

  1. Dcw329

    well that just makes it too easy to hack someones computer… :/ whats the point of the password other than to slow them down now…

  2. mfuasi

    Thanks a handful.For the newbies it will be of great help as this is a common problem.I have a question though,is it compulsory to enter numerics as your password so as for it to function?I used characters at first as i was setting up Ubuntu but the password didnt go through.I had to reinstall Ubuntu to re enter a new password and i used numerics to my success!

  3. J/C.B II

    I must say, Dcw329 is correct, this would make it extremely easy for hackers, or bothersome roommates to get into your computer.

    Is there any way to disable this function so a password reset could not occur?

  4. The Geek

    @All

    I'm going to cover how to prevent this in the next day or so =)

  5. thesquirrelwood

    editing the kernel line is stupid. Just press down again at the grub menu and enter "recovery mode". This is exactly one of the reasons recovery mode is there.

    And to everyone complaining it makes it too easy to hack someones computer: Encrypt your drive if you actually care. Otherwise, anyone with physical access can do whatever they want anyway.

  6. Scott Wegner

    Good article– but like the others above, I would really like to see a follow-up on how to lock-down your GRUB, if not more.

  7. The Geek

    @thesquirrelwood

    That's a good point, I should have included that… updated.

  8. wags062

    @DCw329, @J/C.B II

    You can first edit /boot/grub/menu.lst to remove the recover entries built in to the boot menu that thesquirrelwood mentioned.

    Then, you can put a password on your grub menu so that you need to enter a password before you can edit a boot entry. I forget what the directions are exactly…somebody may want to verify these, but I _think_, off the top of my head, it's…

    1. Open a shell and type the command "grub" to enter the interactive grub shell.
    2. Type md5crypt and hit enter.
    3. Enter the password you want on the menu and hit enter to get the encrypted form.
    4. Edit /boot/grub/menu.lst and add the line: password –md5 encryptedpasswordfromstep3goeshere

    I'm 99% sure those are the accurate steps…haven't had to set up a Linux install from scratch in quite some time (and I'm on my Windows box now, so I can't verify).

  9. Dcw329

    lol… i dont even have linux… so im not too worried… lol… but i thought it was kind-of funny that it is so easy to hack a computer… but if there is a way to stop that (as the geek metioned) then it should be no big deal for you guys…

  10. Dcw329

    now that i think of it… i should probly ask… is there a way to do that with windows? should i be worried about my windows vista laptop?

  11. The Geek

    @Dcw329

    If somebody has physical access to your computer, they can do almost anything they want, unless your hard drive and data are encrypted.

    It's not quite as easy to reset the Vista password, but it is definitely possible.

    [Edit] This article will be the first in a series on this topic… I'll try and cover all the important points for Windows and Linux =)

  12. Srikanth

    Nice post, good screenshots :)

  13. J/C.B II

    I can not believe the amount of comments from this article. The hilarious thing is that if someone did get into my computer, they would find nothing expect a wallpaper.png and perhaps a few comic book files.

    If someone seriously wants to gain access to your computer, they'll find a way too.

  14. Dcw329

    i'm not worried about the CIA trying to break into my computer… but if my friend wants play a prank or something, i don't want him to be able to get it… if it is common knowledge how to break into a computer, i want to stop it… if its difficult, and uncommon… i don't think i need to worry… (i don't have many computer savvy friends… so i'm not panicking…)

  15. Grant

    It is not much harder in Windows. Boot from the EBCD boot disk, and change the password.

  16. harsh

    Its an amazing post..quite useful…….:)

  17. Pinky

    how do i disable that menu for resetting my ubuntu password?

  18. Varney

    I agree with thesquirrelwood. While it's good to take security precautions, if anyone has physical access to your computer, no password is going to save you. If you want to prevent someone from getting your data go with encryption.


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.