Resetting Your Forgotten Red Hat Root Password (RHEL)


A Brief Introduction

Lets be honest, we forget passwords sometimes. It happens. This guide is going to take you through how to reset your forgotten root password for your Red Hat Enterprise Linux machine.

This process will teach you:

  • How to change the bootloader
  • How to modify the GRUB menu
  • How to mount a filesystem from sysroot
  • How to modify the root password ** Please note that this guide assumes a basic knowledge of the linux command line, and how to run commands such as passwd

How to reset your root password

Resetting the root password can be done in just a few simple steps.

Interrupting the boot process

  1. Reboot the system
  2. Interrupt the standard boot process by pressing the arrow keys when the boot-loader selector loads

  3. Press ‘e’ on the first option (GRUB boot loader) to edit the boot config file

  4. Add rd.break to the end of the grub config line

  5. Press ctrl-x to boot, the system will then break at the switch-root

Mounting Sysroot to the filesystem

  1. Mount the /sysroot filesystem using mount -o remount,rw /sysroot

  2. Change root to /sysroot using chroot /sysroot

Changing the root password

  1. Use the passwd command to reset the root password

  2. Create the .autorelabel file to cement the changes (this is done using touch /.autorelabel)

  3. Exit the Chroot shell, back to switch-root by typing exit
  4. Reboot the system, wait for it to come back up, log in as root using the new password