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.
- Power up, or reboot your server (command line, ctrl-alt-del, remote management console, guest virtual machine)
- At the GRUB boot loader, press any key to interrupt the boot process
- At the grub menu, highlight the top entry by using the keyboard's up-down arrow keys
- Press e to edit the entry
- Highlight the line that starts kernel and press e to edit
- Add the word single to the end of the line to boot single-user mode
- Press enter to get back to the previous screen
- Press b to boot into single-user mode
- 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)
- 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).
- Once booted into multi-user mode, you can log in as root using your new root password