How to reset the ROOT password?

Submitted by abhishek on Tue, 02/17/2009 - 07:22
missed a ROOT password now what :(

You can reset the root password if you have physical access to your machine some of the distributions allow you to login in single user mode and once you are logged in you can change the password but what about the distributions which asks me to enter password while logging in the single user mode? eg SUSE is there a solution. yes there is follow the simple steps below to reset your password


Step 1 ) Boot the system and select the normal boot menu from the list. Once selected, in the "Boot Options" box type

    "init=/bin/bash" if you are using GRUB Boot loader

    "linux init=/bin/bash" if you are using LILO Boot Loader

This will give you access to the bash without asking for the password.

Step2 )
Mount your filesystem using the following command

    # mount

Step 3) Make the file system read write if its not already using the following command

    # mount -o remount,rw /

Step 4) If you are lucky enough you can use the passwd command and change the password if it doesnot happen follow the steps mentioned next

Step 5) Edit the passwd and shadow files as follows

# vi /etc/passwd

Scroll down to the "root" line in the passwd file look for root line (something like):


Delete the "x" after "root:" leave the colons! Note: After the modification above line should look like this: root::0:0:root:/root:/bin/bash

Save file and exit. Remember [:wq]

# vi /etc/shadow

Change (something like) this -->

to --> root::::

Note four colons left!
Save the file and exit. Remember [:wq]
use :wq! if :wq doesnot saves it for you

Step 6) Reboot, login as a normal user change the user to root using su then than change the password using passwd

use the commands specified in this blog on your own risk.