Recovering the root password (rd.break)
Sign in to read this lesson
The RHCSA exam often starts right here — "the server's root password is unknown, recover it". In real work too, a forgotten password or a server left behind by an admin who quit comes up often. In this lesson we learn to change the root password on a RHEL 9 server with console access by stopping in the initramfs, plus the important final SELinux step.
What you will learn
- Physical or virtual console access is needed — this cannot be done over SSH.
- In GRUB:
e,rd.breakat the end of thelinuxline,Ctrl+X→ the initramfs shell (switch_root:/#). - The sequence:
mount -o remount,rw /sysroot→chroot /sysroot→passwd root→touch /.autorelabel→exit→exit. - Without
.autorelabelthe new/etc/shadowgets the wrong SELinux context and nobody can log in. - Protection: a GRUB password (
grub2-setpassword) and restricted physical access — anyone with console access knows this method.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.