Lost root password

Any way to recover a lost root password?  I am running RH 5.1.

Who is Participating?
AstromanConnect With a Mentor Commented:

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

nhinmanAuthor Commented:
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?

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

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 :)

nhinmanAuthor Commented:
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).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.