Recover Root Password

First, try this:

Reboot;

For LILO - At the lilo: prompt, type “linux init 1”;

For GRUB -

Hit ESC key after reboot to get the boot prompt

With the default boot highlighted hit the "e" key to edit

Select the line beginning with Kernel and hit "e" key again to edit

add the word "single" to the end of the string with a space between i.e.

kernel /vmlinuz-2.6.9-42.0.10.ELsmp ro root=/dev/VolGroup00/LogVol00 clock=pit single

Then hit "b" to boot into single user mode. If one of those options works, you’ll get a bash shell prompt and may skip the bulleted list below. Otherwise,

  • Insert your boot diskette in the floppy drive or boot cdrom in cd;
  • When you get to the Install or Upgrade? page, type rescue at the boot: prompt and hit enter;
  • When prompted, insert the rescue disk;
  • When it’s finished loading the rescue diskette, you’ll get a bash shell prompt.
  • mkdir /tmp2;

Assuming your hard disk is on /dev/hda1, type “mount -t ext3 /dev/hda1 /repair”; If that fails, you’ll have to improvise. If successful, cd to /repair/etc, and type “cat passwd”: root:Wlkjlk.jo980934:..... ## means you will be editing /repair/etc/passwd root:*:... ## means no editing is required just reboot and use blank password to login root::..... ## means you will be editing /repair/etc/shadow Vi lives in /repair/bin instead of being in your path so do the following: /repair/bin/vi passwd ### substitute passwd with shadow, as necessary. Remove everything between the first two colons of the root passwd entry so it is like: root::... Save the file passwd or shadow with shift-: wq

Edit the file /etc/login.defs so that minimum password length of "0" is allowed

Type “sync” (very important). Hit “^D” to end the bash shell session. The machine should reboot, and you can login as root with no password. Run passwd and enter the new password as soon as possible.

No comments: