Lost Password 

For RH6.2 

Quick Help 

When boot, issue

linux single

will get you to single mode root prompt.

Detail Help 

The most important of runlevel is 1, or single-user mode. Single-user mode is also commonly referred to as troubleshooting mode because the majority of tools available focus on system administration. Since it is a single-user mode, you do not need to log in; you have full access to the system by default. To get in to runlevel 1,type linux 1 when you see the LILO prompt to boot in to runlevel 1.

Once Linux finishes booting in to single-user mode, type passwd root from the prompt and enter a new password for the root account. Once the password has been accepted by the system, you can return to your default runlevel without rebooting the system by typing init 3 or init 5 (depending on which runlevel you want to boot in to) at the command prompt. When Linux returns to the login prompt, you should be able to log in as root using the new password.

General approach 

  1. Reboot (try `[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.

General approach 

Steps:

  1. Make system bootable from CD-rom (either in BIOS or use a boot floppy that will do so).
  2. Put Linux Distribution CD into cd-rom drive and turn on computer.
  3. Pretend to go through installation of distribution and after it asks you to put in the CD-rom and it gets to the next screen you can now go to the second console window.
  4. Press Alt-F2, Alt-F3, Alt-F4, Alt-F5 and then Alt-F1. You should see the various screens with different messages. The one we want is Alt-F2.
  5. Press Alt-F2.
  6. Type "cd /tmp" and press enter. This takes us to a directory where we can make files, directories, etc…
  7. Now we will make a temporary directory and a temporary device for the partition on the hard drive that we want to look at or edit. Type the following:

    mkdir /tmp/my_dir
    mknod /tmp/my_dev b 3 2   #the two is taken from hda"2"
                               above, so should be wherever your
                              "root" partition is.
    mount /tmp/my_dev /tmp/my_dir
    df
  8. "mkdir" makes a directory for us to mount the a partition to. "mknod" makes a device for 2nd partition on the master hard drive (hda2). This lets us "see the partition. In particular, "b 3 2" means "b" is for block device, "3" is the master hard drive on the primary IDE controller and "2" means the second partition. "mount" takes the device we can "see" and puts it on top of the directory /tmp/my_dir. "df" lets you see what filesystems are mounted and where.

      Now we can iether edit the password file or perhaps something like
    turning off xwindows from starting up if you have a computer using
    xdm.  Let's do the password
  9. type: "cd /tmp/my_dir/etc" then "vi passwd"
  10. You need to know how to use vi (a great editor found on almost every UNIX by default). "x" deletes a character, "i" inserts characters, "Esc" turns on and off command mode/insert mode, "wq!" writes, quits and ignores any problems with read-only files, "h" moves one character to the left, "l" one character right, "k" up one line, "j" down one line.
  11. Now in the passwd file press "j" until you get to the line you want to be on "root" (for our example) root:x:0:0:root:/root:/bin/bash # here we want to delete the "x" which is telling us the password is shadowed. Now type "wq!" (without the quotes)
  12. Now type "vi shadow"

        You may see a line for root that looks like this
    root:$1$Upkf7iIA$.nSNmn0MkoRP2srJsUx.0/:11321:0:999999:7:::
    just delete everything between the colons to make it look like
     root::::::::   # that's 8 (eight) colons after the word                   "root"
     Now type "[Esc], :, wq!, enter" to write the file, quit and ignore
    read-only problems.
  13. Now you're done editing the file, what is the problem now? If you reboot you will likely lose all of your changes. You must unmount the directory, THEN reboot.
  14. Do this > "cd /tmp" > "umount /tmp/my_dir" > "df"
  15. After ensuring you unmounted ok, press CTRL-Alt-Del to reboot. Also, take the cdrom out fo the cdrom drive. When your computer restarts I'd recommend having your BIOS boot off the hard drive rather than the CD-rom.

That's it, this is very useful in the case of lost/forgotten root passwords. But it's also good for fixing other problems when you just can't get it booting the right way. As I said, I plagarised the hell out of his article. But it was a great article and helped me out immensly. I hope Mr. Nielsen doesn't mind my copying his work for this forum.