How can I reset my 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.

  • 92 Users Found This Useful
Was this answer helpful?

Related Articles

How can I block a IP address?

To block an individual IP address from accessing your Linux server, you can use the following...

How to use iptables?

Warning Modifying rules on your server can cause the server to become inaccessible on port 22...

How to install rkhunter ?

Rootkit Hunter Rootkit scanner is scanning tool to ensure you for about 99.9%* you're clean of...

How to install syslog server ?

Syslog Features : 1. Logs the daemon information to Remote host2. Logs the daemon information to...

How to get email alert for SSH root login ?

Get Email alert on ssh root login1. Login to your server as root user2. Open file...