Posted by: Odzangba | June 7, 2008

What to do when you lose your password

Disclaimer: This how-to details procedures for gaining root access to linux boxes. If the linux box is not yours, get the (written) permission of the owner… it’ll save you a lot of trouble. I will not be responsible for anything illegal you do with the stuff you learn on this page. :)

Okay, so you lost your password? It’s not the end of the world. But first you need physical access to the box.

1. Boot the machine (and press escape at the GRUB menu loading stage if the menu is hidden).

2. Select the correct entry for booting into your linux system – it usually is the first item and is probably already selected – and press “e” on your keyboard.

3. Select the line that begins with kernel and press “e”on your keyboard to edit it.

4. Now navigate to the end of this line, leave a space and type:

rw single init=/bin/bash.

5. Press “enter” then “b” on your keyboard and wait for the system to boot and give you a command prompt.

6. Now you need to use the passwd command to change your password. Do:

passwd $user

Replace $user with your username

7. Enter and confirm a new password when prompted, and reboot the machine with the reboot command. I sometimes get an error message when I try to reboot; if you run into the same problem, use the power switch. :-D

8. That’s it, you’re okay. :-)


Responses

  1. If you’re using Ubuntu, you don’t even need to edit the Grub menu. It already has a recovery mode/ single-user mode built in. More details here.

  2. Ubuntu certainly makes things easier with its recovery mode option in grub but it will not help you much if a root password has been set. If this is the case, you will be prompted for the root password before you can enter single user mode. Besides, this method is general enough to take of most distros. :)

  3. Ubuntu certainly makes things easier with its recovery mode option in grub but it will not help you much if a root password has been set. If this is the case, you will be prompted for the root password before you can enter single user mode… that’s what step 4 is supposed to take care of. Besides, this method is general enough to be applicable to most distros. :)


Leave a response

Your response:

Categories