Skip to content

Instantly share code, notes, and snippets.

@ZilchBloke
Last active April 17, 2023 08:20
Show Gist options
  • Save ZilchBloke/917e9ee4611f98c585766d760e6dee83 to your computer and use it in GitHub Desktop.
Save ZilchBloke/917e9ee4611f98c585766d760e6dee83 to your computer and use it in GitHub Desktop.
Change root password from Grub (RHEL 9 or CentOS9 specific)

Changing root password from GRUB (without using existing password)

For RHEL9

Steps

  1. When the machine starts, after bios loads up, Grub menu appears (with 2 options for boot kernel)
    Use the arrow key to highlight the rescue kernel (Out of 2 options one will specify to be ..rescue.. kernel) and press e
  2. Use the arrow key to mve the crusor to the end of the line starting with linux..
  3. At the end of the line, append rd.break and press Ctrl+x
  4. mount -o remount,rw /sysroot/ to allow read and write permission to /sysroot/
  5. chroot /sysroot/
  6. passwd to change the password. Shell will prompt to type the new password and retype it to avoid typo.
  7. touch /.autorelabel
  8. exit
  9. exit OR reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment