How to Reset the Root Password of CentOS 8

Hackers have become a lot more sophisticated in recent times, which forces users to come up with strong, unique, and complex passwords. The downside of setting such passwords is that they are not easy to remember, and you can easily forget them. You may also forget your password if you haven’t logged in in a long time.

In this article, we will learn how to reset the root password on CentOS 8. A root account is a unique user account that grants certain privileges to the user.

Resetting Forgotten Root Password

If you have forgotten your password and after trying a lot to remember your old password, you are still unable to get that. Do not worry; we can reset the root password from the GRUB Boot Menu.

For resetting the root password, first, reboot your computer.

When the system restarts, press the “ESC” key immediately to interrupt the boot process.

Select the kernel from the GRUB/Boot menu you want to boot into by pressing the arrow keys.

Pressing ‘e’ from your keyboard will open the editing menu.

In the editing menu, locate the “ro” kernel parameter and replace it with “rw,” and add an additional parameter “init=/sysroot/bin/sh”:

Press Ctrl + X to enter into the single-user mode once you are done with the previous step.

Now run the “chroot /sysroot” command to convert the root file system in read and write mode:

:/# chroot /sysroot

You will now be able to change the root password.

To set a new password for root, input the command:

:/# passwd root

You will then be asked to input a new password and then confirm it. It is best to use a unique, complex, and complicated password that is easy to remember.

Now the next step is to initiate SELinux relabelling. To start the relabelling of SELinux, use the following command:

:/# touch /.autorelabel

After relabeling, Use the following command to save and apply the changes:

:/# exit

Once everything is changed and saved, reboot your computer by using the “reboot” command:

:/# reboot

You may need to wait a few minutes to let the SELinux relabelling process complete.

Upon completion, the system will reboot, and the login screen will appear.

You will have to use the new password; next time you log in as the root user.

Resetting Root password from Terminal

If you need to reset your root password and know the current password, there is no need to do anything complex. Just fire up your CentOS 8 terminal and type the command given below:

$ sudo passwd root

If you are logged in as a root user, you will be asked to input the new password and then confirm the new password.

If you are logged in as a normal user with Sudo privileges, you will be asked to input your current password, the new password, and then confirm the new password.

Please do not select common words as your password.

Once you have successfully reset your root password, you have to log in with this new set password as a root user.


In this article, we’ve learned how to reset a root password that is forgotten. Moreover, we also learned to set up a new root password if you remember your current password.

We discussed the importance of setting a unique password and what kind of passwords we can use. We also touched a bit on the topic of what is a root user.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.