You can never really relate to the priceless beauty and performance of RHEL 8 Linux operating system distribution until you have given it a try. Its user interface is always scaling to better visual appeal, its multi-monitor handling technique is one of a kind, and its security model speaks for itself.
The only thing that can come between an RHEL user’s full exploration of this Linux distribution is human nature. Human nature will convince us to create/set a one-of-a-kind root password on our Linux systems and be responsible for displacing the same unique password.
It is one thing to change a root password and another thing to reset a root password. Changing a root password is straightforward because you still have the old root password in memory. Resetting the root password is another story. It implies that you have no clue or hint regarding this password.
Forgetting the root password forces many users to re-install their RHEL Linux systems, not knowing there is a valid fix.
Changing RHEL 8 Root Password
To successfully change the root password on your RHEL 8 system, you must remember your current root password. A common reason for changing the root password is if you feel like your current root password has been compromised.
The first step is to open the Linux terminal and switch to the root user.
$ sudo su
Next, type the command passwd on your terminal and follow the resulting prompts to successfully change and update the root user password.
The above screen capture confirms the success of the passwd command execution in changing the root user’s password.
Resetting RHEL 8 Forgotten Root Password
This step assumes that we have no idea/hint about the RHEL system’s root user password. To achieve our password reset objective, we first need to restart our RHEL OS and access the Grub boot menu.
Restart your OS and press the
[Esc] key or the keyboard key that is associated with interrupting the boot-up process of your OS. Your keyboard action should lead to an interface similar to the following screen capture:
On your computer keyboard, press the
[e] key, which will display your system’s associated kernel boot parameters. Take note of the line that starts with the word linux and ends with the word quiet.
At the end of this line, add
rd.break so that it looks like the following screen capture.
On your keyboard, press
[Ctrl]+[x] to implement the parameter changes. You will be redirected to a switch_root command-line interface.
At this point, your filesystem needs to be writable, run the following command to remount it.
# mount -o remount, rw /sysroot
We now need to access the chroot environment by running the following command.
# chroot /sysroot
As you have noted, the terminal instance has changed from switch_root to sh-4.4. We can now use this prompt to reset the root user password.
Follow the provided steps to successfully reset the root password in RHEL 8.
The next system boot needs SELinux relabeling enabled.
# touch /.autorelabel
Exit chroot and switch_root environments.
# exit # exit
The system will automatically reboot after SELinux relabeling process is done with its execution. To verify the new root user password, switch to the terminal and sequentially execute the following commands.
Enter your new root user password.
The output should be root.
With this article guide, changing the root user password might be something you were bound to figure out on your own but resetting the root user password will save you from having to forcefully reinstall your RHEL operating system.