Last Updated on 2 months by Sachin G
We have got many changes in Red Hat Enterprise Linux / CentOS , one of the many changes GRUB 2 version. Reset the password through single user mode we are using in RHEL 5 and RHEL 6 version but here it will be different from older versions.
We may need to reset the root password if we forget it, or if it has been stolen or changed by someone else. In such cases, we won’t be able to log in or access the system to make any changes, so resetting the password becomes necessary. So Don’t worry! with a few steps , you can reset the root password and regain full access to your linux system. In this post i am usnig single-user mode method.
Use below procedure carefully and mistake can make your machine unstable, first try l test machine on your own risk.
Show Forget root password and Reboot the system
Here I am showing the screen of trying to log in through GUI in Linux box and not getting success via root in login through GUI, same will be implemented as a command line interface.
Booting into Single-User Mode
In new version of GRUB , we will use single-user mode in rescue mode , In GRUB2 we have the Rescue Mode / Emergency mode in new version , which makes it perfect for password recovery.
Restart the system and hold down the Shift or Esc key (depending on your system) right after the BIOS/UEFI screen to access the GRUB menu. On some systems, the GRUB menu may appear automatically.
Press e
to edit the GRUB boot parameters. Find the line starting with linux
or linux16
and At the end of this line, append the following text:
rd.break
This step prepares the system to boot into single user mode in RHEL 9 for password recovery.
Resetting the Root Password
Now the Emergency shell mode or rescue shell mode will available for reset 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 below commands .
# mount –o remount,rw /sysroot
Now, access the root environment:
# chroot /sysroot
Now, you’re inside your Linux system in single user mode . Give the passwd command in the command line and press the same password twice to reset the root password.
To avoid SELinux issues after reboot:
# touch /.autorelabel
This ensures proper Red Hat Linux recovery practices are followed.
Type exit two times after running an autorelable activity. The first will exit the chroot jail, and the second will exit the initramfs debug shell.
Find below all the commands history that we use to reset the password.
Now we have to reset the password of root . After exit two times system will boot again and check given root credentials is working properly.
I have got root screen .. 🙂 . The process itself wasn’t too difficult, but it definitely reminded me how important it is to keep secure and memorable passwords. I felt a mix of satisfaction and a bit of frustration that I even had to go through this, but in the end, it was a good learning experience.
Resetting a lost root password in RHEL 9 might sound technical, but with the right method — specifically using GRUB menu edits and single user mode in RHEL — the process is straightforward and secure.
Whether you’re a system administrator or a student preparing for Certification, knowing how to reset root credentials is an essential Linux troubleshooting command skill.
I’m Sachin Gupta — a freelance IT support specialist and founder of techtransit.org. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!