Thursday, 4 February 2010

lost root password change on linux

let's say you've lost your root password, or simply cannot log in as root after a hard drive install, and have no privileged users on your system. I'm about to show you how to get back in the game as root with a quick and dirty password-change hack.

For this tutorial, everything that is italicized is a user action. Anything in "angle brackets" is a keystroke. If it has a + beside it, it means press the keys at the same time.

// Changing the root password:

= - = - = - = - = - = - = - = - = - = - =

Reboot your computer. Wait for the grub screen... Press "ESC" when you're prompted.

Highlight the first option.

Press "e".

Highlight the kernel line.

Press "e".

Press "TAB". You'll get an error message.

Press "ESC".

Press "e" again.

Using your arrow keys, scroll back and change ro to rw

At the end of the line add: init=/bin/bash

Press "Enter"

Press "b"

Type at the prompt: passwd root

Enter the new password twice.

Press "CTRL"+"d" to cause a nice Kernel Panic. This will cause your system to hang.

Press and hold your power button till it shuts down. Power back up and let it boot into BackTrack normally.

Log in as root with your new password.