Solved

forgot root password on RH Linux 6.1

Posted on 2000-03-23
7
700 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

690 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