How can I reset my root password?

This article explains how to reset the root password if you no longer know it. You will require KVM access to your server in order to perform these steps.

CentOS/Fedora

  1. Through the KVM, initiate a restart of your server by sending the shutdown command:
  2. When it comes to the Loading CentOS/Fedora Grub Bootloader screen hit esc. (Right after you get to the network boot screen it will be at the grub bootloader screen)
  3. At the grub screen select the default OS & hit e to edit.
  4. Then you should have 3 lines of text. Select the line that starts with kernel & ends in root=label=/
  5. Press e to edit the line, and at the end of the line add a space and then put a capital S.
  6. Then enter to save & go back to the previous screen.
  7. Then hit b for boot with that line selected.
  8. It will enter you in single user mode and you get a bash prompt.
  9. Then you can just type ”’passwd”’ enter new password and reboot.

You will not need to re-edit the grub loader it reverts to normal after the next reboot.

Debian

Reboot and edit the Grub kernel line add a space then the following at the end of the line. (like ‘Alternate Method’ above)

Then run this command to remount the root partition in read/write mode.

and reset the root password as normal with the ‘passwd’ command.

 

Tagged:

Rate This Article

(180 out of 343 people found this article helpful)

About The Author