How to Reset Forgotten Root Password in CentOS 8

It’s not uncommon for users to forget their root password. This happens especially if you haven’t logged in as the root user for long periods of time. In this brief guide, we will walk through the steps of resetting a forgotten root password in CentOS 8 Linux.

Read Also: How to Set Up Automatic Updates for CentOS 8 and How to Reset Forgotten Root Password in RHEL 8

Let’s get started…

Reset Forgotten root Password in CentOS 8

First, reboot or power on your CentOS 8 system. Select the kernel you want to boot into. Next, press ‘e’ on the keyboard to interrupt the boot process and make changes.

CentOS 8 Boot Menu

CentOS 8 Boot Menu

On the next screen, locate the ro (read-only) kernel parameter as highlighted below.

Locate Kernel Parameter

Locate Kernel Parameter

Replace the kernel parameter ro with rw and append an extra kernel parameter init=/sysroot/bin/sh. In a nutshell, simply replace the kernel parameter ro with rw init=/sysroot/bin/sh.

Replace Kernel Parameter

Replace Kernel Parameter

Once done with making the changes, hit Ctrl + X combination on the keyboard to enter single-user mode.

Next, run the command below to mount the root file system in read and write mode.

:/# chroot /sysroot
Mount Root File System

Mount Root File System

You can now change the root password by executing the command:

:/# passwd root

Provide a new root password and confirm it. For best practice select a password with a combination of uppercase, lowercase, numerical and special characters to boost password strength.

Reset Root Password

Reset Root Password

Next, run the command below to enable SELinux relabelling.

:/# touch /.autorelabel
Enable SELinux Relabelling

Enable SELinux Relabelling

To apply the changes, exit and reboot the CentOS 8 system.

:/# exit
:/# reboot
Reboot CentOS 8 System

Reboot CentOS 8 System

Upon reboot, the SELinux relabelling process will commence. Give it about 3 minutes.

SELinux Relabelling Process

SELinux Relabelling Process

When the relabelling process is done, the system will reboot and thereafter, you will be presented with a logon screen upon which you can now log in as the root user with the new password that you just set.

We hope this tutorial will be beneficial to you. Feel free to weigh in your feedback if you are stuck.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

James Kiarie

This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

10 Responses

  1. Jalal says:


    Very useful Article for me.

    Thanks a lot

  2. Alexey says:

    Thank you!

    Is there any difference in resetting the root password between Centos and Red Hat?

    Are you planning to write a similar article about Debian/Ubuntu?

  3. David says:

    This is the functional equivalent of using rd.break?

    • James Kiarie says:

      Hey David, yes it is. A similar article on how to do it on RHEL 8 is scheduled within the course of the week.

    • James Kiarie says:

      Hey Gnu, This is a guide on resetting a forgotten password on CentOS 8. A guide for RHEL 8 is coming up before the week comes to an end.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.