Recovering from a lost root password under Linux

This article provides a quick procedure on how to recover a lost root password frm virtually any version of Linux which uses the GRUB boot loader.

  1. Power up, or reboot your server (command line, ctrl-alt-del, remote management console, guest virtual machine)
  2. At the GRUB boot loader, press any key to interrupt the boot process
  3. At the grub menu, highlight the top entry by using the keyboard's up-down arrow keys
  4. Press e to edit the entry
  5. Highlight the line that starts kernel and press e to edit
  6. Add the word single to the end of the line to boot single-user mode
  7. Press enter to get back to the previous screen
  8. Press b to boot into single-user mode
  9. One the OS has booted into single-user mode, type passwd and hit enter, to change the root password (you will be prompted to reenter the password twice)
  10. Type reboot and hit enter to reboot the system into multi-user mode (run-level 3, 5 or whatever your system state is normally set too).
  11. Once booted into multi-user mode, you can log in as root using your new root password