Solved

forgot root password on RH Linux 6.1

Posted on 2000-03-23
7
689 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
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now