Identity & Access
Conceptual illustration: a silver administrator key unlocking a luminous secure terminal tile with a stylized Linux penguin silhouette.

Reset a Forgotten Root Password on RHEL 8 or 9

The GRUB/rd.break method described here is scoped to RHEL 8/9 and equivalent legacy installations, not every RHEL or appliance release.

Use this recovery procedure on a system you administer when normal privileged access is unavailable. It requires console access and a reboot. If the encrypted root volume needs a recovery key or the bootloader is protected, obtain the authorized credentials first. A password reset does not bypass disk encryption or a protected bootloader.

Recover The Root Password

Prepare and interrupt the boot menu

Schedule the outage, confirm a usable backup and keep the VM or physical console open. At the GRUB menu, select the required kernel and press e. Find the kernel line, which can begin with linux, linuxefi or linux16 depending on the system, and append rd.break. Removing rhgb quiet is optional. The edit applies to this boot only.

GRUB editor showing the selected RHEL boot entry
Original RHEL boot-editor example; the kernel-line label can differ by release.

Press Ctrl+X to boot the modified entry. The system should stop in an initramfs emergency shell before switching to the installed root filesystem.

Mount the installed system and reset the password

mount -o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel
exit
exit

Enter the new password interactively. The first exit leaves the chroot; the second resumes boot from the recovery shell. On an SELinux-enabled installation, /.autorelabel requests relabeling during the subsequent boot. The password change is already written to the password database; relabeling corrects security labels so authentication can work. It is not what makes the password change persist.

SELinux relabel requested with the autorelabel file
Original example requesting an SELinux relabel after the password reset.

Allow the relabel and verify access

A full relabel can take time and may cause another reboot. Do not interrupt it because the console appears quiet. Sign in through the console and verify that SELinux has returned to the expected mode with getenforce. Confirm normal services and any administrative password-management process before closing the console.

If access still fails

  • Check for an account lockout or an expired password separately; a reset and a lockout-counter reset are different operations.
  • If /sysroot is not present or the installed root filesystem cannot be mounted, stop and use the recovery instructions for that release and storage layout.
  • For RHEL releases outside this scope, and for vendor-managed appliances, use their specific recovery procedure. Do not assume the same boot parameters apply.

For Photon-based systems, see the separate Photon OS root account recovery guide.

References

Leave a Reply

Your email address will not be published. Required fields are marked *