Last Updated on 5 months by Sachin G

We have got many changes in CentOS Stream or RHEL Versions from old versions. One of the many changes  GRUB 2 version. Every Linux system administrator should know the reset the lost root password.

Different methods are available to reset new root passwords by Live CD or edit shadow files or mount the root file system. Here we are doing this not through any external media.

Below is the procedure to reset the root password, if we forget or lose our root password in CentOS Stream or RHEL and Alma-Linux Versions.

Use the below procedure carefully Mistakes can make your machine unstable, first, try l test the machine at your own risk.

Show Forget  root password and reboot the CentOS server

The below snapshot shows the screen where user root is trying to log in with the last remembered password but is not successful in logging in through the GUI. Similarly, this will be implemented as a command line interface.

GRUB 2  Edit Menu Option

Edit the kernel parameter line with Rescue Mode / Emergency maintenance mode.

First, start or reboot your machine and wait for the GRUB 2 booting menu screen to load, it will show in the image below, and press the “e” edit key to edit the grub2 menu option after grub2 is loaded.

In editing GRUB 2 menu option go down. Search “Linux” line using the up and down

arrow keys and go to the end of the line and add  “rd.break” keyword.

After setting rd.break keyword at the end of the line press ctrl+x  to boot or start the process.

Reset the root password

Now the Emergency shell mode or rescue shell mode will available for resetting the password.

First, we will remount the sysroot file system in read and write mode. Then use chroot to got into a chroot jait at /sysroot through the below commands.

 # mount –o remount,rw  /sysroot
 # chroot /sysroot 

Now we will give passwd command in the command line and press the same password twice for reset root password.

Finally, ensure that all unlabeled files (including shadow) get relabeled during boot with the command below.

 # touch /.autorelabel 

Type exit two times after running the autorelable activity. The first will exit the chroot jail and the second will exit the initramfs debug shell.

Find below all the command history that we use to reset the password.


Now we have to reset the password of root. After exiting two times system will boot again and check given root credentials is working properly.

I have got root screen  ..   🙂