This tutorial will go through the steps to reset the root password in CentOS. In Linux, root privileges (root access) is similar to Administrative account in Windows. A root user will have complete access to all the files, applications, configurations, and system functionality. Most user accounts on Linux run with limited privileges, which is recommended if you’re using the system.

The reason for this is security, which keeps the users from damaging the system permanently or accidentally exposing it to threats. That being said, if you are (or have) a root user and forgot the password, it will be impossible to have complete access to the system.

This guide will explain how you can reset the root password in CentOS systems. The following method is suitable for the following versions:

  • CentOS 6
  • CentOS 7
  • CentOS 8


  • A server/machine running a CentOS operating system
  • Basic knowledge of Linux commands

How to change the root password

First, let’s go through the process of changing the root password. To change the root password, enter the following command:

sudo passwd root

When you enter this command, the system will prompt you to enter your existing password. Enter the current password and enter the new password, respectively.

Note that this command will work for the root user or any user with root privileges.

How to reset root password in CentOS

In order to reset your root password in CentOS, you will need to access the boot menu. To access the boot menu for 1Gbits VPS servers, you need to be connected to the server through a console. To access the console:

  • Login to the 1Gbits dashboard
  • Head over the control panel
  • Click on the VNC icon
  • Select “Launch HTML 5 VNC Client”

  • You will see the VNC window similar to the one shown below.

If you would like to learn how to make your VNC server, check here! Read more

In order to access the boot menu:

  • Restart the system
  • Tap the Esc key about once per second to launch the GRUB menu
  • Use arrow keys to highlight the Linux version you booting from

  • Press to enter the GRUB edit mode.
  • Scroll down till you find the line starting with Linux 16. Here change the ro with rw init=/sysroot/bin/sh 

  • Now press Ctrl + x to start the system on single-user mode (this is needed to reset the password). 
  • To access the system, enter the following command.

chroot /sysroot

  • Reset the password by:

passwd root

  • Update the SELinux information using this command:

touch /.autorelabel

  • Exit the chroot and reboot your system.



Once your system is restarted successfully, confirm that your new password works by logging in.

For 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 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.

Final words

If you already have access to your user accounts, resetting or changing your password in the Linux VPS system is quite simple. It can be more challenging if you’ve lost or forgotten a password, but you can get your accounts back with a little creative restarting and editing some files.

Let us know if you encounter any errors when using the above commands.

People also read: