Skip to main content

% 16k.es

RHEL8 root password recovery

When studying to apply for a Redhat certification I tend to go over root password recovery again. Just in case 😄

rhel 8

A normal installation of RHEL8 will display the grub menu when booting. When the menu appears on screen press e:

GRUB

Go to the end of the linux line (which is longer than one row) and add rd.break at the end of the line:

GRUB

Press Ctrl+x to boot and wait for the prompt.

GRUB

Now you have to mount (rw mode) the sysroot partition, chroot to it and change the root password:

GRUB

If SELinux is enforcing, this is mandatory

Before rebooting, a file /.autorelabel must be created in the root directory to instruct SELinux to relabel filesystem upon next boot. Then, type exit twice:

GRUB

The boot process will take longer than usual because of relabeling, but you will be able to login with your new root password.