RHEL 9 – change root password when not known

Reboot the system using either hard boot or soft boot.

Interrupt the boot process when the grub kernel choice comes up by using the down arrow key.

Go back to the top line (or other kernel if you prefer) and hit ‘e’ to temporarily edit that kernel’s boot parameters.

Find the line that starts with ‘linux’ (usually the fourth line) and go to the end of the line with the ‘end’ key.

Add the following to the end of the line:

init=/bin/sh

Then hit Ctrl-x to proceed. This should bring you to a blank screen with only ‘sh-5.1#’ (or whatever kernel version)

Enter the following lines:

/usr/sbin/load_policy -i
mount -o remount,rw /
passwd root (then enter your password twice)
/sbin/reboot -f

After the system reboots, test your new root password. If you boot to grub there may be a different user showing in the login screen, be sure to switch to root before you login.