Reset Your Lost Root Password

Posted: 25 Jul 2005

If you have forgotten root password don't worry, there is an easy way to reset it and create a new one

let's get to it

It's important to disconnect your computer from the network because you will be working with root privileges. This inherently makes your computer temporarily more susceptible to hacks.

boot from the install CD

Boot from your first install CD and press F1 at the first screen. Then choose "Rescue System" from the menu.

At the prompt type:

# root

*note* - You do NOT need a password.

edit the "passwd" file

At the next prompt, enter:

# cd /etc
# vi passwd

scroll down to the "root" line.
In the passwd file look for root line. It should looks something like this:

root:x:0:0:root:/root:/bin/bash

Delete the "x" after "root:". It's important to leave the colons.

To delete letter under the cursor press ESC key and "x" -> so you are deleting letter "x" by pressing sequence ESC key "x"

After the modification above, the line should look like this:

root::0:0:root:/root:/bin/bash

Now, save the file and exit by pressing ESC then "wq" and "enter".

Now we're going to edit the "shadow" file.

edit the "shadow" file

Next edit:

# vi shadow

Press ESC then "x" (x will delete letter under cursor)

change root line from something like:

root:$2a$05$sin5i458ghsdfg8076t5ymp4y;jgslkdbvffd bshmRK:12856:0:10000::::

to this:

root::::

*note* - four colons should be left!

Save the file by pressing ESC and "wq".

If something goes wrong during the editing process, press ESC followed by "q!".

Log out, reboot, set your new password

Reboot your computer, log in as your normal user, and from the console window enter:

$ su
# passwd

And here you'll set the new root password.

Log out of root, and in as your normal user, and you're done!

Addendum.

If you have lost user password: log in as a root and type

#passwd user_name

enter a new user password.

You're done.



Informacja z serwisu http://www.djack.com.pl