Lost Root password


Lost the Root password

When you lost root password how you can recover and login back in to the system?
To login in to system there are so many ways to get root access depending on security level of the system.
Method1: When there is no password set to access runlevel 1.

Here are the steps to change your root password the most esiest way is as follows..

1. Start your computer when you see Redhat Linux boot loader(GRUB menu where you can see all the Operating system's in the system) select the redhat linux and press "e", and select second line where you can set the temporary runlevel for the system to boot

2. You will notice that now you can edit boot loader command arguments now again press "e" and edit the line to add single or 1 without quots at the end of line.

3. Press enter to return to previous screen

4. Press b to boot with this new argument which will run Linux into single user mode. Please make sure that you see single at the end of line.

5. Now you will get root login with out asking for a password in single user mode.

6. Use "passwd" command to change your password.
here it will not ask previous password so you can just enter new password.

7. When updateing the password in runlevel1 if the server is not allowing you to change password giving you error, this is due to /etc/shadow file issue.
In order to resolve this issue execute the following command and then try to change the password


7.After changing the password just type exit command which will take you to default runlevel of the system or just Reboot and use the new password.

Method2: When GRUB boot loader is protected with a password.
When the GRUB boot loader is protected by a password the above mentioned method will not work, so how to login to the system?
In order to retrive root password we have to have first RHEL cd or a live CD(may be konpics/Ubuntu) .

It is easy to boot using the first Cd.
then enter into the rescue mode
just type linux rescue and boot prompt with out quoat

Now we will be logged in to a normal shell, do the folowing steps
Step1 : change the root partation to /mnt/sysimage

chroot /mnt/sysimage

Step2 : Now just change the password

Step3 : Exit from rescue mode

then login with the new passwd
And if you don't have the correct version CD, you can boot from a live CD,
Mkdir /a
mount ... /a
vi /a/etc/password

delete the password in /etc/shadow for root
Now it will come up with no root password (change immediately).

Method3: This method will give you how to retrive your lost root password, not for changing the root password
So how to recover the root password? We can use Rainbow tables technic to do this.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here