Recover a root password on Linux systems

This How-To will guide your through successfully recovering (resetting) the root password on most Linux based systems.

Generally all Linux distributions now use GRUB bootloader, but for older systems still using LILO bootloader, we also provide a LILO procedure towards the bottom of this page. Be sure to follow the method applicable to your system.


Before getting started, we suggest you Learn Linux Basics and follow these precautions.

Steps to follow for systems using GRUB bootloader

Step 1

Turn on/reboot your system. After the BIOS post, GRUB menu will load and display a list of kernels to boot from. Press e to edit the first GRUB menu option.

If you cannot see your GRUB menu options press ESC key when prompted.
GURB menu should look similar to this:

Step 2

Using the arrow keys, select the kernel line and press e key again to edit.

Step 3

Kernel boot options may differ on your system, just be sure to append init=/bin/bash to end of the line and then press ENTER.

Step 4

Now that our boot options have been changed we are ready to boot the operating system. Press b key to boot.

Step 5

After successfully booting you will be presented with a command prompt. Here we need to mount / and /proc partitions with the following two commands:

mount -o remount,rw /

mount -o remount,rw /proc

Step 6

Reset the root password by issuing the passwd command.

passwd

Step 7

Before rebooting the system, it is a good idea to run the sync command.

sync

reboot

You should now be able to login into the system with your new root password.




Steps to follow for systems using LILO bootloader

Step 1

At LILO bootloader type linux single and press the ENTER key:

Boot: linux single

Step 2

When presented with the command prompt, issue the passwd command.

passwd

Step 3

Before rebooting the system, it is a good idea to run the sync command.

sync

reboot

You should now be able to login into the system with your new root password.