Table of Contents
Introduction
Welcome back to day 20!. Today’s focus is on how to recover or rescue the forgotten root password in RHEL 9.
Yes, it happens that one might wake up one day and you can no longer remember your system root password. So, what do you do as the Linux System Administrator?
Let’s get into it!
Step-by-Step Guide on Recovering the Root Password
- Start your virtual machine (I am using VirtualBox) or type reboot in your console.
- Once it is about to boot, quickly use the up and down arrow keys to select the option with 'rescue' in it.
Hit the letter 'e' on your keyboard quickly on the GRUB boot entry screen to enter edit mode. (This is for editing the parameters)
Look for the line starting with
linux
orlinux16
. Now, at the end of that line, add the following inside.
rd.break console=tty1 selinux=0
With this we do not need to do the 'touch /.autorelabel' that is creating the autorelabel file in the root directory anymore.
- Click Ctrl+X to start (Press Enter for maintenance if prompted, to see the shell)
- Now you on the shell, you need to remount and give it read/write mode. Type this prompt
mount -o remount,rw /sysroot - # press enter chroot /sysroot - # The root we want to reset password for. Now press enter. passwd - # Type this and press Enter, you will be prompted to enter the new password and retype it again to confirm it.
- Now type exit
Type exit again
The system will boot and request you to login. Now login as the root and the new password.
That's it! We have successfully recovered our root password. No more panics!
Conclusion
Recovering root password is a must-know skill and very important for every Cloud, Linux or DevOps Engineer.
If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 21!
Let's Connect!
If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.
#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer
Top comments (4)
Man I always forget steps like these when I need them most, so this kinda guide is a lifesaver. Absolute clutch move.
Thank you Nathan! Them articles comes handy especially when simply written.
Thanks Amanda! I can’t wait to try this.
Thank you for reading, hoping to read your article when you implement it.