How to reset a lost root password
If you have forgotten root password don’t worry, there is an easy way to reset it and create a new one. This tutorial will also give you an idea on the need to protect a physical linux box.
Step 1.
Disconnect computer from the network (you will work with root privileges)
Step 2.
Boot from your first install CD/DVD and press F1 at the first screen, then choose “Rescue System” from the menu and at the prompt type:
#root
- NOTE: You do NOT need a password
Step 3.
Next at the prompt enter:
# cd /etc # vi passwd
scroll down to the “root” line
In the passwd file look for root line (something like):
root:x:0:0:root:/root:/bin/bash
delete the “x” after “root:” 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 line shoul look like this:
root::0:0:root:/root:/bin/bash
Save file and exit:
Press ESC then wq and enter
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
root::::
note four colons left!
Save the file:
ESC next wq
If something went wrong with editing press ESC and next q!
it is q with exclamation mark: “q!”
reboot your computer, log in as your normal user, and from the console window enter:
$ su # passwd
And set the new root password. Log out as root:
You just set a new root password.







