How to Change or Reset your forgotten root password in RHEL?

Did you forget your RHEL Linux root password? Don’t worry, resetting a root password is not a difficult task. It can be completed in a few steps by accessing the kernel parameters from the GRUB boot loader. After that, log in with your new password.

Now, let us see the steps to change and reset the root password on RHEL:

Reset Forgotten Root Password in RHEL

  1. First, reboot your system. At the boot GRUB menu, select the Kernel and press the ‘e’ key to interrupt the boot process.
  2. After entering the Kernel boot parameter, go to the line that starts with Linux and press ctrl+e to go to the end of the line. Add the parameter rd.break at the end of the line and press ctrl+x to start.
  3. Next, you will enter the Emergency Mode Prompt. Press Enter to proceed with the process in the shell prompt.
  4. By default, the file system is mounted under the /sysroot directory in read-only (ro) mode. So, ensure to remount the /sysroot directory with read and write permission.
# mount | grep sysroot
  1. Remount the /sysroot directory with read and write permissions, then confirm the permissions again.
# mount -o remount,rw /sysroot/
# mount | grep sysroot
  1. After mounting the drive, enter the following command to make changes in the system files.
# chroot /sysroot
  1. Now reset the root password with the following command:
# passwd
  1. After changing the password, enable the SELinux relabeling process.
# touch /.autorelabel
  1. At last to start the SELinux relabelling procedure, enter the exit, and log out.

Once finished, the system will reboot and ask you to log in as the root user with a new password, which usually takes a few minutes.

Change the Root Password in RHEL

  1. Log on to the RHEL Server using SSH or Console.
  2. Run the passwd command to change a password for the root user:
sudo passwd root
root@new:~$ sudo passwd root
New password:
Retype new password:
passwd: password updated successfully
  1. If you already have root access and want to change your existing root password, you can modify it with just the ‘passwd’ command.
root@new:~# passwd
New Password:
Retype new password:
passwd: password updated successfully

4.To re-enable the root account, enter the command

sudo -i or su

Now, you have successfully changed or reset your root password in RHEL.

Hope this step helped to change or reset the forgotten root password. If you still need any assistance, feel free to Get Assistance.

Also check:

Steps to Install LibreNMS on CentOS 8 / RHEL 8

Steps to Fix “apt-get: command not found” error in Linux

To get more updates you can follow us on Facebook, Twitter, LinkedIn

Subscribe to get free blog content to your Inbox

Written by actsupp-r0cks