How to Reset Red Hat Root Password on Boot

The root password of a system is important and complying well with a secure password standard. If the existing root password is no longer satisfactory or is forgotten, you can change or reset it both as the root user and a non-root user. To reset root password of Red hat system, you need to follow this simple guides.

Resetting the Forgotten Root Password as a non-Root User

If you are a member of the administrative wheel group you can reset the forgotten root password easily with passwd command.

To change or reset the root password as a non-root user that belongs to the wheel group, use:

$ sudo passwd root

Done! But the time we concern about is when we can not reset the root password with a non-root user.

Reset Red Hat Root Password on Boot

When you are unable to log in as a non-root user or do not belong to the administrative¬†wheel¬†group, you can reset the root password on boot by booting to emergency environment. Let’s do it.

  1. Try to reboot the Red Hat system.
  2. On the GRUB 2 boot screen, press the e key to interrupt the boot process.
Reset Red Hat Root Password on Boot
Reset Red Hat Root Password on Boot

We need to append the rd.break in the GRUB bootloader to the line that starts with ‘linux’ to get in to emergency mode, if you don’t know the current ‘root’ password.

3. Move down to the Linux line and press Ctrl+e to jump to the end of the line then add the rd.break at the end of the line. See the screenshot for reference.

Boot Linux in Emergency Mode
Boot Linux in Emergency Mode

4. When done, just press Ctrl+x to reboot and start the system with the changed parameters.

5. One you boot it into emergency mode, remount the file system as writable.

The file system is mounted as read-only in the /sysroot directory. Remounting the file system as writable allows you to change the password.

mount -o remount,rw /sysroot
Mount File System Writable
Mount File System Writable

6. Enter the chroot environment using the chroot command.

chroot /sysroot
Reset-Linux-Root-Password
Reset-Linux-Root-Password

7. Type passwd root and press enter then enter the new password for root account

8. Once your reset the root password, try to enable the SELinux relabelling process on the next system boot by creating a .autorelabel file.

touch /.autorelabel

Finally, exit from chroot environment and switch_root prompt and restart your Linux machine.

Don’t forget! What command would you use to force an SELinux autorelabel at boot time?

Wait until the SELinux relabelling process is finished.

Note that relabelling a large disk partition might take a long time. The system reboots automatically when the process is complete.

Leave a Comment