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.
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.
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.
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
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.