Lost root password

nhinman used Ask the Experts™
Any way to recover a lost root password?  I am running RH 5.1.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Boot up linux. At the lilo prompt type:

LILO: linux -S (or whatever your kernal image is called).

This will boot up into single user mode.

You can now edit the password file /etc/passwd manually. Look for the line that looks something like:


Delete all the alphanumeric garbage. (if you want to be sure it's the right field, count in the colon delimited fileds in other entrys. Quite a lot of users like daemons etc should have a '*' in this filed locking out the user.

Now reboot the machine and the root user will not have a password anymore.

Happy recovery (or hacking...)

use the rescue disk coming along with redhat
at the boot promtp type:

linux single

then mount your linux partition:

mount -t ext2 /dev/hda2  /

and finally run the command

passwd root

and change the root password


Serena77's comment gave me what I needed to change the root password.  Redhat 5.1 did not recognize the '-S' switch at the LILO: prompt.  It did recognize 'single' per Serena77's comment but I didn't need to use the rescue disk.  I also did not have to mount the linux partition.  It was done automatically.  

So all I had to do was enter 'linux single' at the LILO: prompt and enter 'passwd root' at the BASH# prompt.

Thanks Serena77!  ...and thanks Astroman for your good attempt.

I think Serena77 actually deserves the points.  How do I give them to her?

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Woops, you can't now, you gave them to me. I'm surprised the -S switch didn't work though. Maybe it should've been -s. It's definatly one or the other because I've done it before and it worked then!!

It never occoured to me to use the passswd command to update the root password - a bit dim really of me. Essentially, by editing the password file by hand thats what you would be doing.

I had to go through all this because after installing redhat 5, when it set my rootpasswordon install, I couldn't log in with it!



Zeldar: If you really want to give me some points you can post another question with the title 'points for serena77' or something ;)  Anyway the most important thing is that you solved the problem. Sometimes a simple reply  is a lot better than just points :)



Astroman:  Perhaps you could do what Serena77 is suggesting and split the points with her?  50/50 or whatever?
Thanks again, Zeldar

I can't, because expert points and spending points are 2 different things.

I have 5 spending points, and about 3000 expert points. The only thing I can think of is registering again as a second person and donating a load of points to serena77..

I wish I could spend expert points because I've got loads(well, a few), and bugger all spending points because I spent them all reading useless PAQ's.

Sorry about the whole thing, but at the end of the day, they are only abstract, and not anything real ;)

Sorry serena(77).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial