How to Reset Root Password on CentOS 8

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

CentOS 8 Boot Menu

Find ro (read-only) kernel parameter as showed below.

Locate Kernel Parameter
Locate Kernel Parameter

Replace ro with rw and append an extra init=/sysroot/bin/sh.

Replace Kernel Parameter

After making the changes, press Ctrl + X on the keyboard to enter single-user mode.

Now mount the root file system in read and write mode.

:/# chroot /sysroot
Mount Root File System

Now set your root password as you like:

:/# passwd root
Reset Root Password

Now, run the below command to enable SELinux relabelling.

:/# touch /.autorelabel
Enable SELinux Relabelling

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

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

Reboot can take some times. After reboot your centos 8 system login with your new root password.

Was this helpful?

2 / 0

Leave a Reply 2

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



Thanks, it worked!



Hello. remarkable job. I did not expect this. This is a remarkable story. Thanks!