?
Solved

forgot root password on RH Linux 6.1

Posted on 2000-03-23
7
Medium Priority
?
703 Views
Last Modified: 2008-03-06
I built a new rh linux 6.1 server about 2 months ago and just now starting to use it.  I hadn't yet made any user accounts and I forgot what root's password is.  Is there any way to wipe out what password is there, maybe booting from cdrom?  How would I access the passwd file? Any ideas?
Thanks
Jak
0
Comment
Question by:j_k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:fbjean
ID: 2652055
It is write in the book.
There is no way to recover a forgot root passwd .
You just have to reinstall.
No other way.
Sorry.

Good luck
0
 
LVL 1

Expert Comment

by:matt_hook
ID: 2652179
I disagree totally with fbjean.

Never say never man! nothing is impossible or out of the question.

You can recover.

Basically you boot to single user mode!

at the lilo prompt type "linux single <return>".
you will come to the prompt right away
no login or anything (which is really a bit of a security hole but if phsical access to the computer is protected then it's not).
If lilo does not allow you to type into the prompt then you may need to hold down the shift key to get access to it.
if it prompts you for a password I hope you know it... if not there are other ways.

Since you are root, type chpasswd
type in a new one.. reboot.

If you cannot get into single user mode because it has been secured (sometimes this is done)

If the above didn't work then see if you can create yourself a linux boot disk.

When you've done that boot up the disk.
If necessary login.
Then at the command prompt type:
mount /dev/hda1 /mnt/<something> or mount /dev/sda1 /mnt/<something>
or whatever partition and drive contains
the /etc directory tree.

This is where it gets interesting.

If you're running a ramdisk type of boot repair disk copy the file from /etc/passwd on the disk you just mounted to the /etc/passwd on your repair disk.

Next type passwd root
enter in a new one.

copy the passwd file back to the real /etc/passwd on your mounted disk which might be /mnt/<something>/etc

reboot and viola! you can login using the password from before.

by the way,  backup your passwd file before you make changes.

If you're using shadow passwords.. umm, not sure but the procedure might be more tricky..

another thought is, modify your system to allow you to login in single user mode... then follow the original procedure which was easier..
As for enabling you go single user I'm not sure how to fix it if it is passworded single user.. it seems to me that you can make the single user logon screens appear by modifying the boot scripts. so there are lots of ways it can be done.

I hope you find this a satisfying answer.
0
 

Author Comment

by:j_k
ID: 2653276
Thanks Matt,
This is the kind of info I was looking for.  I'll try somethings today like that.
Jak
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 

Expert Comment

by:nholowat
ID: 2653590
This is a cut and paste from Linux Gazette from the answer guy... on how to recover froim a lost password,it's a good source for alot of info.

1. Reboot
(try [Ctrl]+[Alt]+[Delete])
2. During the LILO prompt type:
(kernel/image name) init=/bin/sh rw
.... note that's usually going to be just:
linux init=/bin/sh rw
3. This should start the Linux kernel,
with the root filesystem mounted in read/write mode. The cool thing is that none of your normal init processes (like the gettys that ask for your name and call the login program) will be started.
4. (Maybe) mount your /usr filesystem with a command like:
mount /usr
5. Change your root password with a command like:
passwd
6. Flush the cache buffers:
sync; sync; sync
7. (Maybe) unmount /usr:
umount /usr
8. Remount the root fs in readonly mode:
mount -o remount,ro /
9. Let init clean up and reboot the system:
exec /sbin/init 6
.... there is a "6" (six) at the end of that command.
That's it. Don't worry about the couple of lines where I said '(Maybe)' --- you can follow those steps too, if you don't understand. The errors from unnecessarily executing those steps are harmless.
0
 

Author Comment

by:j_k
ID: 2654128
Thanks,
Lilo: linux single was all it took to get to the # prompt.  passwd command worked from there. Then booted normally and sucessfully logged in.  All Done.  I believe Matt_hooked should propose his as an answer since that was were I got the info first.
Jak
0
 
LVL 1

Accepted Solution

by:
matt_hook earned 200 total points
ID: 2655170
I'm guessing this is how I propose this to be the answer and get the points.

Basically you boot to single user mode!

at the lilo prompt type "linux single <return>".
you will come to the prompt right away
no login or anything (which is really a bit of a security hole but if phsical access to the computer is protected then it's not).
If lilo does not allow you to type into the prompt then you may need to hold down the shift key to get access to it.
if it prompts you for a password I hope you know it... if not there are other ways.

Since you are root, type passwd<return>
then type in a new password. reboot
and login with the new password.

0
 

Author Comment

by:j_k
ID: 2655838
thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question