Resetting a forgotten CentOS root password

If you have forgotten the root password of your CentOS server, you can reset it from the server console like this:

  1. When the GRUB screen appears during boot, press any key to stop the countdown.

  2. Select the default boot entry and press e.

  3. On the next screen, find the line that starts with kernel and press e while it is selected.

  4. Go to the end of the line, add a space, type single and press Enter. You return to the previous screen.

  5. Press b and wait for the system to boot.

  6. When the system drops to the # prompt, type this command and press Enter:

    passwd root
    
  7. Enter your new root password.

  8. Type this command and press Enter to restart the machine:

    reboot
    
Was this article helpful?