Solved

forgot root password on RH Linux 6.1

Posted on 2000-03-23
7
693 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
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 how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

809 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