LLI Wiki — My Digital Knowledge Base

CentOS 8: reset a forgotten root password

Reset the root password from GRUB using rd.break and chroot /sysroot.

On a CentOS 8 machine whose root password is lost, you can reset it from the console at boot time, without external media. Reference: Tecmint, reset forgotten root password in CentOS 8.

Procedure

  1. Reboot the machine and, in the GRUB menu, press e to edit the boot entry.
  2. On the line starting with linux, append rd.break at the end.
  3. Boot with Ctrl+X. The system stops in an emergency shell (initramfs).
  4. Remount the filesystem read/write and change into it:
mount -o remount,rw /sysroot
chroot /sysroot
  1. Set the new password:
passwd root
  1. Request an SELinux relabel on the next boot, then reboot:
touch /.autorelabel
exit
exit

Notes

Mastodon LLIMastodon SocialFosstodon