How to Reset Root Password in RHEL/CentOS and Fedora

This article will walk you through the simple steps to reset the root password in RHEL-based Linux distributions like CentOS 8 and Fedora 35/34.

Note: This article is about resetting the root password, not finding the password. After resetting the password, you will login with the new root password.

How to Reset Root Password in RHEL/CentOS & Fedora

First, reboot your system and at the grub boot menu select the kernel (usually the first option) that you want to boot from and press the ‘e’ key on your keyboard.

How to Reset Root Password in RHEL/CentOS & Fedora

On the next screen, you will see the kernel’s boot parameters as shown below, here find the line that starts with kernel= and add parameter rd.break at the end as shown and then press Ctrl + x key combination.

How to Reset Root Password in RHEL/CentOS and Fedora 34

On the next screen, you will enter the emergency mode, here press the Enter key to enter the shell. Now make sure to confirm that you remount the sysroot folder with read and write permissions. By default, it is mounted with read-only mode specified as ro.

# mount | grep sysroot

How to Reset Root Password in RHEL/CentOS and Fedora 35

Now remount the sysroot folder with read and write permissions and confirm the permissions again. Notice that this time, the permissions have changed from ro (read only) to rw (read and write) as shown below.

# mount -o remount,rw /sysroot/
# mount | grep sysroot

How to Reset Root Password in RHEL/CentOS and Fedora 36

Next, mount the root file system in read and write mode with the following command.

# chroot /sysroot

Next, use the passwd command to reset the root password with the new password and confirm it.

# passwd

How to Reset Root Password in RHEL/CentOS and Fedora 37

At this point, you have successfully reset your root user password. The rest is to relabel all the files with SELinux.

# touch /.autorelabel

How to Reset Root Password in RHEL/CentOS and Fedora 38

Finally, type exit and then logout to start the SELinux relabeling process.

How to Reset Root Password in RHEL/CentOS and Fedora 39

This usually takes a few minutes, and once completed, the system will reboot and prompt you to log in as the root user with the new password.

How to Reset Root Password in RHEL/CentOS and Fedora 40

And that’s how you reset the root password in Linux distributions RHEL/CentOS 8 and Fedora 35/34.

Alternatively, you can also log into the root account in Kali Linux here.

Leave a Reply