Fixing Root Password Problems
PASSWORDS


Q. I forgot the root password! The root password expired! What do I do?

Contributed By Kurt Wall and Matt Carpenter. Bill Campbell reviewed it, found notable shortcomings and fixed them, making substantive updates in the process.


Method ONE.

If you've simply forgotten THE password

"Martin Meyer" <martin@thinkmeyer.com>

restart the system and at the lilo prompt type [ imagename] single

[imagename] simply refers to the kernel prompt eg

linux single

This starts linux in runlevel 1 instead of the standart runlevel 3 or 5, requiring no password and opening a shell as root on a single virtual console.  You can then issue the passwd command as you normally would, then type 'init 3' or 'init 5' to continue to your normal runlevel.


Method TWO:

  1. The first step is booting the system using a method that bypasses password prompts. How to do this depends on the boot loader. If you use LILO or GRUB, we've got you covered. If you don't use LILO or GRUB, you're on your own, but the information in this step may still help you.

    •     If your system uses the LILO boot loader, do the following. After the box completes its POST routine, you should see the boot:      prompt. At the prompt, type linux init=/bin/sh and      press Enter.    
          boot: linux init=/bin/sh
    •     If your system uses the GRUB boot loader it works this way:     

      • Using the arrow keys, select the kernel you want to boot.
      • Type e, which will allow you to edit the boot string.
      • Use the arrow keys to move the cursor to the line that starts kernel = , then press e again to edit the line.
      • Type Ctrl+e or use the arrow keys to move the cursor to the end of the line.
      • Add a space, followed by init=/bin/sh, then press Enter.
      • Type b to boot.

  2. Eventually, you will be presented with a shell prompt like so:
       bash# 
    
    At that prompt, remount the root file system in read/write mode (if you wish, clear the screen of graphical detritus using the clear command:
        bash# clear
    
    bash# mount -n -oremount,rw /
  3. Now, change the password. As usual, you will need to type the password twice.
        bash# /usr/bin/passwd root
    
  4. Sync the hard drive by typing sync; sync; sync
  5. Remount the hard drive read-only:
        bash# mount -n -o remount,ro /
    
  6. Reboot the machine.

    At this point I recommend logging as root using the password you just changed, and run the passwd command again to insure that all the authentication files are updated correctly.



searchSearch Index