- Boot into a limited emergency shell from GRUB.
- Remount the root filesystem read-write.
- Set a new root password.
- Trigger SELinux relabeling and resume a normal boot.
- Edit the GRUB entry to boot a limited shell.
- Remount the root filesystem read-write.
- Set a new root password.
- Trigger an SELinux filesystem relabel and continue booting.

Prerequisites
- Physical console or remote KVM access to the system (required to edit GRUB).
- If the system uses full-disk LUKS encryption, be prepared to enter the passphrase during early boot.
- Access to the system console is a powerful privilege—protect it (see warning below).
Anyone with physical or console access can gain root by booting into a rescue/emergency shell. Secure the boot process (BIOS/UEFI protections, GRUB passwords, or secure management interfaces) to prevent unauthorized access.
- Reboot and enter GRUB edit mode
- Reboot the server. When the GRUB menu appears, use the arrow keys to highlight the kernel entry you want to boot, then press
eto edit the selected entry.
- Edit the kernel command line
- Locate the line beginning with
linux(sometimeslinux16or referencingvmlinuz) and modify it:- Change
rotorwif you want the kernel to mount root read-write immediately. Note: even if you change this, the emergency shell often mounts read-only, so remounting may still be necessary. - Append
init=/bin/bashto the end of the line so the kernel launches a shell as PID 1.
- Change
linux line (wrapped for readability):
- Remount, reset password, and relabel SELinux
- The system will drop you to a
bashprompt. Even if you setrw, the root filesystem is often mounted read-only in this mode. Execute the following commands from the emergency shell:
If SELinux is enabled, run
touch /.autorelabel on RHEL systems after changing the root password from an emergency shell. Without relabeling, SELinux contexts may be incorrect and the system can fail to boot normally.- After
exec /sbin/initthe normal boot process resumes. During the next boot you will see SELinux relabeling messages; this can take time depending on filesystem size. Once relabeling completes, log in asrootusing the new password.
Notes and security considerations
- Physical or console access is required to perform these steps; anyone with such access can gain root by booting into a rescue shell. Protect console/boot access accordingly (e.g., secure GRUB with a password or use appropriate BIOS/UEFI protections).
- If your environment uses full-disk encryption (LUKS), you will be prompted for the passphrase during early boot. You cannot bypass disk encryption by editing GRUB.
- Consider enabling a GRUB password or other boot-time protections in environments where physical access is not tightly controlled.
- RHEL Boot Process and GRUB: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/
- SELinux and relabeling: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/