To recover the root password you need to use the rescue mode, below you can find URL to the article about the rescue mode:

Rescue mode

When you have switched the server into the rescue mode and logged into it via SSH, you need to mount and chroot your root "/" partition. In our example it is sda3 partition:

mount /dev/sda3 /mnt


Now chroot it with the following command:

chroot /mnt /bin/bash


When you mount the root partition and chroot it, you must only type the command to change the password:

passwd


Type the new password twice. Now you can switch the server into the normal boot by reboot the server. When the server is online after a restart, in the normal boot you will be able to use the new password.

Was this answer helpful? 127 Users Found This Useful (146 Votes)