Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email 



LOST ROOT PASSWORD


Here is part two. Yesterday we had forgotten our user password and disaster strikes again today we forgot the root password.

First, disconnect your PC from the net, pull the cable out !



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
Esc
ZZ

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 !!


Bruno


-- May 21 2003 ( Revised Dec 9 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email