In this article, we will review a scenario that may appear on the RHCSA9 exam. The RHCSA9 exam series articles are designed to increase your
In this RHCSA9 Exam Series: Resetting the Root Password article, we will review how to change or reset the root password in RHEL9. There’s a slight difference to the way this done as of the 9.0 release and the date of this publication.
Breaking into a RHEL9 machine and changing the root password is almost as straight-forward as before with the exception being, you now have to select the rescue option in the grub menu (bottom of the list). Before we begin, we’re making a few assumptions.
Photo by admingeek from Infotechys
Photo by admingeek from Infotechys
You will be presented with the option to hit the [Enter] key for maintenance mode or the [Control-D] to proceed with booting into rescue mode.
Press the [Enter] key for the maintenance option.
Press Enter for maintenance
(or press Control-D to continue):
sh-5.1#
Enter the following command (below) to mount /sysroot partition in read/write mode. Then, press the [Enter] key to continue.
sh-5.1# mount -o remount,rw /sysroot
Now enter the chroot command (below) to enable the password change and hit the [Enter] key to continue.
sh-5.1# chroot /sysroot
We can now proceed with changing the root password by simply entering the passwd
command.
sh-5.1# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
sh-5.1#
As a result of changing the root password, selinux is set to the incorrect context. Therefore, create the following hidden file under the root directory (below) to ensure the selinux subsystem detects and relabels all files to the correct context.
sh-5.1# touch /.autorelabel
sh-5.1# exit
exit
sh-5.1# exit
Enter the exit command and press [Enter] twice to escape maintenance mode and proceed with the boot process.
Photo by admingeek from Infotechys
The boot process will finally arrive at a login prompt where you can test your new root password. If you can log on successfully, congratulations! You have successfully broken into and reset the root password on a RHEL9 machine!
Was this article helpful to you? If so, leave us a comment. We’d love to hear from you!
Related Posts
In this article, we will review a scenario that may appear on the RHCSA9 exam. The RHCSA9 exam series articles are designed to increase your
In this section of the RHCSA9 Exam Series: Understand and use essential tools, we will examine some of the essential tools that may appear on
Looking to enhance your Linux skillset? RHCSA 9 Container Management Skills introduces a new section on container management, making it a must-have competency for any