How to Reset the Root Password on Rocky Linux 9
Before moving forward to the password reset process, let’s divide this guide into two parts. The first part is resetting the passwords with the root access and the second part is setting the password without the root access.
Change/Reset the Root Password
Changing the root password is simple. First, access the system as the root:
After entering as the root user, run the following command. The system will ask you to enter the password:
We recommend you to enter the password carefully due to security reasons. Once you provide the new password, press the “Enter” key. Now, the system will ask you to re-enter the password, so type it down and save the changes. After resetting the password, the terminal will show you the following result:
Reset the Root Password from Boot Parameters
First, reboot the system, highlight the Linux entry, and press the “E” key.
After pressing the “E” key, you can access and edit all the boot parameters. Here, find the line that starts with linux and add the following at the end of it:
As you can see in the previous image, we have the rhgb quiet at the end of the line. You can remove it and add the rd.break enforcing=0. After successfully making the changes, either press the F10 or CTRL keys. Then, press the “X” key on your keyboard to boot the currently modified parameters.
At the next window, you need to provide the read and write access to your sysroot filesystem:
Write the previous command correctly and then press the “Enter” key. Now, run the following command to access the sysroot file through the chroot command:
After that, run the following commands to reset the root password. Then, exit the current boot window:
exit
Finally, change the read and write privileges from the sysroot file. Then, exit to reboot the system safely:
exit
Conclusion
This is all about the simple approaches that you can try to reset the root password on Rocky Linux 9. We divided the guide to explain the password reset process in various conditions. Remember to follow the second method correctly because if you use any wrong command, it can cause severe damage to your system and its boot process.