Saturday, January 16, 2010

Let's Try this to Reset Linux Password!

First, try this:

  1. Reboot;
  2. At the lilo: prompt, type “linux init 1”;
  3. If that works, you’ll get a bash shell prompt; go to step 4, below.
  4. Otherwise, go to step 1 below.


I’m running Redhat 5.2 and 6.0, but I know that the procedure is similar on other distributions; however, I’ll only describe the procedure for Redhat.

You need the Redhat boot diskette and the Redhat rescue diskette; it probably helps to have another Linux machine available.

  1. Insert your boot diskette in the floppy drive;
  2. When you get to the Install or Upgrade? page, type rescue at the boot: prompt and hit enter;
  3. When prompted, insert the rescue disk;
  4. When it’s finished loading the rescue diskette, you’ll get a bash shell prompt.
  5. mkdir /tmp2;
  6. Assuming your hard disk is on /dev/hda1, type “mount -t ext2 /dev/hda1 /tmp2”;
  7. If that fails, you’ll have to improvise.
  8. If successful, cd to /tmp2/etc, and type “cat passwd”; if the root passwd entry looks like this, you’re in business: “root:Wlkjlk.jo980934:.....” (where the stuff after the second colon is readable text, like numbers & so on)
  9. If the root passwd entry looks like this, “root:*:...” you’re also in business;
  10. ...and if it looks like this, “root::.....”, you’re already OK. Just reboot and login as root with no passwd. Exit this procedure.
  11. If it looks like “root:x:....”, then you need to operate on the shadow file, not the passwd file; everything else from here on out applies to whichever file you’re editing.
  12. You need to edit the passwd or shadow file, but vi lives in /tmp2/bin instead of being in your path.
  13. Type “/tmp2/bin/vi passwd” (or shadow, as appropriate).
  14. Remove everything between the first two colons of the root passwd entry; it should end up looking like this “root::...
  15. Save the file (passwd or shadow)!!!!!
  16. Type “sync” (very important).
  17. Hit “^D” to end the bash shell session.
  18. The machine should reboot, and you can login as root with no password.

No comments:

Post a Comment