Rocky Linux

How to Reset the Root Password on Rocky Linux 9

The root password in Linux provides administrative privileges including the complete system’s control. Usually, a root account is not enabled in Linux distros for obvious security reasons. This helps in preventing authorized or accidental modifications in the system.Hence, securing the root password is essential to manage the root privileges. However, there are some situations where the users forget the password and sometimes lose the root privileges. If you are looking for a method to reset the root password, this short guide is for you. In this guide, we will explain the various ways to reset the root password on Rocky Linux 9.

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:

su -

After entering as the root user, run the following command. The system will ask you to enter the password:

sudo passwd root

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:

rd.break enforcing=0

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:

mount -o remount,rw /sysroot

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:

chroot /sysroot

After that, run the following commands to reset the root password. Then, exit the current boot window:

passwd root

exit

Finally, change the read and write privileges from the sysroot file. Then, exit to reboot the system safely:

mount -o remount,ro /sysroot

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.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.