How to Break / Reset Root Password in RHEL 8/CentOS 8

Sometimes it is required to reset the root password of your Red Hat Linux machine due to various reasons. In this tutorial, we will learn how to break or reset the root password in Red Hat Enterprise Linux 8 or CentOS 8. The steps are very simple and easy to follow, so let’s check them out without any delay.

 

How to Break Root Password in RHEL 8 and CentOS 8

 

Stept to Reset/Break Root Password in RHEL 8/CentOS 8

 

1. Reboot your Red Hat server or machine and in the grub menu press the “e” key to edit the kernel boot parameters as shown below.

 

Grub menu - Reset root password

 

2. Now go to the line which starts with “linux” and go to the end of the line. You can do that by pressing CTRL+e key or using your arrow key.

Now, in this line just add rd.break and press CTRL+x to start the machine.

 

rd.break - Reset root password

 

3. Now you are in emergency mode, here you have to type few commands. First of all, you have to remount /sysroot as read & write and then chroot it. Chroot command basically changes the apparent root directory for the current running process and its children.

# mount -o remount,rw /sysroot
# chroot /sysroot

Now that you have changed the directory, just type the “passwd” command to reset the root password. Once the root password is set, just create a file called autorelabel in the root directory with the help of touch command.

# passwd
# touch /.autorelabel
# exit
# exit

 

Reset Root password

 

After creating the file you just have to exit the shell. That’s it!

 

As you have reset the root password in your RHEL 8 machine, now it’s time to test it. Once you exit the above step, it will directly take you to the login prompt. Just log in with the new password and take a breath.


We hope this article might have been helpful for you all. If you have any doubts or issues please let us know through your comments.

If you want more Unix/Linux article, please do subscribe to Storage Tutorials by Email. Also, do not forget to share this article with all your SysAdmin and Linux enthusiast friends.

Buy me a coffeeBuy me a coffee

Add Comment

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