Sunday, February 21, 2010

Recover ROOT Password :

 

First of all disconnect your PC from the internet connection !

Steps to recover lost root password:

(Here I'm assuming that you are lot allowed to boot into linux maching through single user mode or your Bootloader is password protected. )

Step 1: For Redhat and Mandrake:

Then boot from your first install CD and as the very first screen comes up hit F2 and type:

rescue ( For RedHat "linux rescue" )

and the computer will boot in rescue mode.

It will show a few alternatives, select : ¨mount the existing partitions¨ and go to the shell/console prompt.

( Booting Mandrake in "failsafe" from the Lilo menu does the same )

Step 1: For SUSE:

Boot from your first install CD and press F1 at the first screen, then choose "Rescue System" from the menu and at the prompt type "root" ( you do not need a password )

Step 1: For other distro's

Boot from the first install CD ( or any Live CD like Knoppix ) and at the bootprompt type:

CODE

linux single

( For Knoppix: knoppix single )

And it will boot in "single user mode" and you will get an odd looking prompt like “sh-2.05b#”

Alternative for step 1

Sure with most Live and Rescue CDs you can also just boot in the live version, mount the partition and, as root, make changes to the files indicated below:

Step 2

CODE

# cd /etc

( if you boot from knoppix first cd to the partition your lost-password-distro is on )

We need to change two files; ¨passwd¨ and ¨shadow¨:

CODE

# vi passwd

( opens the file )

< i > ( puts vi in insertmode )

This is the first line:

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

Make it:

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

So just get writ of the ¨x¨ do not touch the ¨:¨ ( colons )

Save the file:

Esc

ZZ

Second file to be changed:

CODE

# vi shadow

( open the file )

< i > ( insert mode )

The first line is a long scrambled line of characters, just make it:

root:::: ( four colons ! )

Save the file and quit editor.

wq

Now you can reboot your computer. Log in as normal user, open a console and type:

CODE

$ su

# passwd

And set the new root password !

Log out as root:

Ctrl+d

And the job is done !!

WARNING: Only after setting your new root password it is safe to connect your computer to the internet or local network again !!

 
Things You Should Know About Linux !!!