Wednesday, April 26, 2023

How to reset your RHEL 8 system password?

Reset your RedHat system password?

1. Reboot the system and interrupt the boot loader sequence by pressing any key.

2. Move the cursor to the entry (the kernel) that you want to boot.

3. Press e to edit the selected entry. Move the cursor to the kernel line

4. Go to end of the line and append rd.break at the end of the line.

5. Press “Ctrl+x” and reboot the system. You will see a root shell with the root file system which ia mounted read-only on /sysroot.

6. Remount /sysroot as read-write filesystem.

7. Switch to a chroot where /sysroot is treated as the root of the file system tree

8. Reset your new root password

9. Make sure that all unlabeled files (including /etc/shadow at this point) get relabeled during boot

10. Type exit twice. The first will exit the chroot jail, and the second will exit the initramfs debug shell. Let the system continue booting, perform a full SELinux relabel, then reboot again.