How to reset root password?

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

CentOS/Fedora

  • Through the KVM, initiate a restart of your server by sending the shutdown command:
    shutdown -r now
    
  • 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)
  • At the grub screen select the default OS & hit e to edit.
  • Then you should have 3 lines of text. Select the line that starts with kernel & ends in root=label=/
  • Press e to edit the line, and at the end of the line add a space and then put a capital S.
  • Then enter to save & go back to the previous screen.
  • Then hit b for boot with that line selected.
  • It will enter you in single user mode and you get a bash prompt.
  • 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)

  init=/bin/sh

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

  mount -o remount,rw /

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

Radhe

Radhe Dhakad is Support Executive and Network Admin at RackBank Datacenters Pvt. Ltd.. He is our curious techie who loves experimenting on servers and likes to pen down whatever he explores new on server technology!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© Copyright 2013-2021 RackBank© Datacenters Pvt. Ltd.


Data Center in India

Rated 4.7/5 based on 31 reviews at Google+