Last Updated on 3 weeks by Sachin G

Forgetting the root password on a Linux server feels like locking yourself out of your own house — except this “house” is a mission-critical system. Over the last decade, working as a Linux system administrator, I have been asked countless times:

  • “How to recover root password in Linux Red Hat 9?”
  • “How to recover root password in Linux Red Hat 10?”

The good news is that resetting the root password in Red Hat Enterprise Linux 9 and 10 (RHEL 9 / RHEL 10) is not only possible but also straightforward if you know the right steps.

Changes in RHEL 9 and RHEL 10

With Red Hat Enterprise Linux / CentOS, we’ve seen many changes over the years — one of the biggest being the switch to GRUB 2. In older releases like RHEL 5 and RHEL 6, admins often used the single-user mode method to reset the root password. But with RHEL 9 and RHEL 10, the procedure is different due to GRUB 2 and enhanced security features like SELinux.

Why You May Need to Reset the Root Password

You might need to reset the root password in RHEL 9 or RHEL 10 if:

  • You’ve forgotten it
  • It was changed by someone else
  • It was stolen or compromised

In any of these cases, you won’t be able to log in or make critical changes to your system. Don’t worry — with just a few steps, you can reset the password and regain full access to your Linux system.

What This Guide Covers

In this tutorial, I’ll walk you through:

  • The single-user mode method (adapted for GRUB 2)
  • Methods to reset root password in RHEL 9 and RHEL 10
  • Exact commands and screenshots
  • Troubleshooting tips for GRUB and SELinux issues
  • FAQs answering common sysadmin questions like “How to reset forgotten root password in RHEL 9 and RHEL 10?”

⚠️ Warning: Use this procedure carefully. A small mistake can make your machine unstable. Always test first on a non-production system before applying changes to live servers.

Why Root Password Recovery in RHEL Matters

The root account in Linux is the superuser — it controls package installation, user management, firewall settings, services, and pretty much everything else.

If you forget it on a production server, you can’t:

  • Restart critical services.
  • Add new users or fix permissions.
  • Apply urgent security patches.

That’s why knowing how to reset forgotten root password in RedHat Linux is a must-have skill for any sysadmin, whether you’re working with physical servers, VMs, or cloud environments

Showing Forget  root password and Reboot the system

Here, I am showing the screen while I try to log in through the GUI on a Linux system. The root login fails in the GUI, but I can perform the same action using the command line.

Showing Forget  root password and  trying to access via root user .

Method to Reset Root Password on RHEL 10 Single-User Mode

RHEL 10 follows a slightly different sequence. Apart from the systemd.unit=rescue.target method, you can also use the init=/bin/bash trick:

In GRUB, press e.

On the kernel line, append:

init=/bin/bash
GRUB version 2.12 boot menu in a virtual machine, showing the Linux kernel loading command line with parameters like vmlinuz, root=/dev/mapper/rhel-root, and initrd
Screenshot by TechTransit.org: GRUB Boot Menu Editing Process

Boot.

Remount the root filesystem:

mount -o remount,rw /

Run:

passwd root

Followed by checking the SELinux status, which is disabled. When the system tries to boot with SELinux enabled, the login process will be denied access to the /etc/shadow file because of this incorrect label, and you will not be able to log in. To fix this, you must tell the system to relabel the files on the next boot. This is done by creating a hidden file named .autorelabel in the root directory.

touch /.autorelabel

And end command exec /sbin/init is used in this specific recovery scenario to terminate the current shell (the temporary root shell) and force the kernel to proceed with the normal system initialization process.

ash shell prompt (bash-5.2#) showing a successful password reset process using the mount -o remount,rw / and passwd commands, with SELinux status disabled
Screenshot by TechTransit.org: Password Reset Process in Bash Shell.

Method to Reset Root Password in RHEL 9 Single-User Mode

Booting into Single-User Mode

In this version of GRUB, we will use single-user mode in rescue mode. In GRUB2, we have the Rescue Mode/Emergency Mode in the the new version, which makes it perfect for password recovery.

Steps to Reset Root Password on RHEL 9

Restart the system and hold down the Shift or Esc key (depending on your system) right after the BIOS/UEFI screen to access the GRUB menu. On some systems, the GRUB menu may appear automatically.

  1. Restart the server.
  2. At GRUB, press e to edit boot parameters.
  3. On the kernel line, append:
Grub 2 Single user rescue emergency mode
GRUB 2 Booting Menu Screen
rd.break
Screenshot of GRUB kernel line with rd.break — Screenshot by TechTransit.org: Adding rd.break for RHEL 9 recovery
Screenshot of GRUB kernel line with rd. break — Screenshot by TechTransit.org

Boot with Ctrl+X.

The system stops at an emergency shell.

Remount sysroot with write permissions:

mount -o remount,rw /sysroot
chroot /sysroot

Now reset the root password:

passwd root

Update SELinux contexts:

touch /.autorelabel
exit
exit
reboot

This step prepares the system to boot into single-user mode in RHEL 9 for password recovery.

This is the standard reset root password RHEL 10 single-user mode procedure.

RHEL7_root_password6

Method: How to Recover Root Password in Linux Red Hat via Rescue Mode

If GRUB is locked with a password or you don’t have console access, Rescue Mode is your friend.

Steps:

  1. Boot from the RHEL installation DVD/ISO.
  2. At the boot menu, choose: Troubleshooting → Rescue a Red Hat system
  3. Once in the rescue environment, run: chroot /mnt/sysimage passwd root
  4. Exit and reboot.

This is often the only option for cloud servers where GRUB is inaccessible.

I have got the root screen. 🙂 .

LoggedIn Screen of RHEL 9 After Changing Credentials

Troubleshooting: SELinux & GRUB Issues

  • If you forget to run touch /.autorelabel after resetting the password in RHEL 10, SELinux may prevent logins.
  • If GRUB is password-protected, you’ll need installation media to boot into rescue mode.
  • If passwd fails, make sure /sysroot is mounted with write access.

FAQ Section

Q: How to reset the root password in Linux without rebooting?

A: Not possible if you’re fully locked out. Only works if you have a sudo-enabled user.

Q: How to reset forgotten root password on RHEL command line?

A: Use GRUB with rd.break or init=/bin/bash to drop into an emergency shell and reset it.

Q: How to change the root password in Linux if forgotten?

A: Boot into single-user or rescue mode and run passwd root.

Best Practices After Resetting Root Password

  • Change the root password to a strong, unique one immediately.
  • Create a secondary sudo admin user as a backup.
  • Document credentials securely (use a password manager).
  • Limit physical and console access to trusted staff only.

Learn Smarter. Level Up Faster →

Want to master Linux, DevOps, Ansible, or Cloud workflows the smart way? I’ve curated a list of top-rated, real-world Udemy courses — based on student reviews and practical feedback.

Visit the Recommended Courses page to explore and enroll in courses trusted by the community.

See Curated Courses →

Forgetting the root password isn’t the end of the world. Whether it’s RHEL 9 or RHEL 10, you now know multiple ways to reset it: single-user mode, GRUB, rescue mode, or even through sudo if available.