Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Reset the Root Password on CentOS

Last Updated: Tue, Jul 28, 2020
CentOS System Admin Troubleshooting Guides

Introduction

If you are locked out of your CentOS instance and have lost access to the root account, you need to boot into single-user mode and reset the root password. These steps apply to CentOS 6, 7 and 8.

How to Reset the Root Password on CentOS

  1. Access the instance console in the Vultr customer portal.

    Vultr Web Console

  2. Click the Send CtrlAltDel button on the top right of the web console.

    Send CtrlAltDel

    You can also click the Server Restart icon.

    Server Restart

  3. Follow the steps below for your version of CentOS.

CentOS 6

  1. As the system boots, GRUB prompts you to press any key to stop the boot process. Press a key quickly; you only have a few seconds. If you miss the prompt, you need to restart the server from the control panel and try again.
  2. At the GRUB prompt, type A to append to the boot command.
  3. Add a space and the text single to the end of the line.
  4. Press ENTER.
  5. The system will boot, and you will see the root prompt.
  6. Type passwd and follow the prompts to change the root password.
  7. Run reboot to reboot the server.

CentOS 7

  1. As the system boots, press ESC to bring up the GRUB boot prompt. The prompt happens early in the boot process. If you miss the prompt, you need to restart the server from the control panel and try again.
  2. At the GRUB boot prompt, press E to edit the first boot option.
  3. Find the kernel line starting with linux16.
  4. Change ro to rw init=/sysroot/bin/sh.
  5. Press CTRL+X or F10 to boot into single user mode.
  6. Access the system with the command: chroot /sysroot.
  7. Type passwd and follow the prompts to change the root password.
  8. Run reboot -f to reboot the server.

CentOS 8

  1. As the system boots, press ESC to bring up the GRUB boot prompt. The prompt happens early in the boot process. If you miss the prompt, you need to restart the server from the control panel and try again.
  2. At the GRUB boot prompt, press E to edit the first boot option.
  3. Find the kernel line starting with linux.
  4. Change ro to rw init=/sysroot/bin/sh.
  5. Press CTRL+X or F10 to boot into single user mode.
  6. Access the system with the command: chroot /sysroot.
  7. Type passwd and follow the prompts to change the root password.
  8. Run touch /.autorelabel to force file system relabeling.
  9. Run exit.
  10. Run logout.
  11. Run reboot to reboot the server.

Want to contribute?

You could earn up to $300 by adding new articles