How to Change and Reset Forgotten Root Password in RHEL 9

While installation of RHEL 9, the installer recommends we choose a complex password and while making the password complex enough, the chances of forgetting our password are quite high. And things get even more complex when your user is not even added to the wheel group (which allows a normal user to elevate root privileges for a small amount of time).

This tutorial will guide you on how you can change your forgotten root password in 3 scenarios and we are quite sure that you’ll be able to recover your forgotten password at the end of this guide.

Method 1: Changing Root Password in RHEL 9

So if you are a root user and want to change your existing root password, you can accomplish this task with a single command.

# passwd
Change Root Password in RHEL 9
Change Root Password in RHEL 9

And it will ask you to enter your new root password. For confirmation, it will ask you again for entering the new password and it will throw a message saying “all authentication tokens updated successfully”.

Method 2: Changing Root Password as Sudo User

For the majority, this will be the case where the user is added to the wheel group and want to change the root password. Thankfully, you can change your root password even if you don’t know the current one.

To change your root password as a wheel group user, utilize the given command:

$ sudo passwd root
Sudo User Change Root Password
Sudo User Change Root Password

First, you’ll be asked to enter your user password and after that, you’ll be allowed to change your root password by entering it twice and for confirmation.

Method 3: Changing Forgotten Root Password in RHEL 9

This method is for those who are not root users or their local user is not added to the Wheel group and still wants to change or reset their forgotten root password.

This is the most complex method and while using this method, make sure you read commands twice before applying them as we will be dealing with GRUB.

Step 1: Enter GRUB Edit Mode

To enter GRUB edit mode, first, we have to reboot our system. When you see GRUB 2 screen, press the 'e' key to interrupt the boot process.

RHEL Grub Boot Menu
RHEL Grub Boot Menu

Once you press 'e', it will show us kernel boot parameters.

Kernel Boot Parameters
Kernel Boot Parameters

Step 2: Edit Kernel Boot Parameters

Once you enter Kernel boot parameters, go to the end of the line which starts with linux. The easiest way to do that is first to go to the line that starts with linux and press CTRL + e to jump to the end of the line.

View Kernel Boot Parameters
View Kernel Boot Parameters

Once you are at the end of the line, add rd.break and press CTRL + x to start the system with changed parameters.

Edit Kernel Boot Parameters
Edit Kernel Boot Parameters

Step 3: Reset Forgotten Root Password

You will be given an emergency mode prompt. From here, we will be mounting our drives, entering into chroot environment, and changing our root password. Press Enter and the sh-5.1 prompt will appear for further process.

RHEL Emergency Mode Prompt
RHEL Emergency Mode Prompt

By default, the file system is mounted as read-only under /sysroot directory. By using the given commands, we will be remounting them to make them writable and change our password.

# mount -o remount,rw /sysroot

After mounting drives, let’s enter into chroot environment which will allow us to make changes directly to system files.

# chroot /sysroot

Finally, we can change our root password by utilizing the given command:

# passwd
Change Forgotten Root Password in RHEL 9
Change Forgotten Root Password in RHEL 9

After changing the password, let’s enable SELinux relabeling process on the next system boot.

# touch /.autorelabel

Important: We are not running any scripts here, so make sure you use /.autorelabel correctly.

After changing the password and relabeling, let’s exit chroot environment by the given command:

# exit

Similarly, to exit from the sh-5.1 prompt, we will be using the given command:

# exit

Step 4: Verify Root Password

To verify whether we have successfully changed our root password or not, log in as a normal user and open the terminal emulator and run an interactive shell as root, utilize the given command:
$ su

Enter the newly configured root password. To print the username associated with a current user ID, we will be using the given command:

# whoami
Check Root User Login
Check Root User Login

And it will return as “root”.

This guide has shown 3 methods by which you can change your forgotten root password in RHEL 9. But if you still have any doubts, feel free to mention them in the comments.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “How to Change and Reset Forgotten Root Password in RHEL 9”

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.