How to reset the root password in a Red Hat Enterprise Linux

If you are studying for the Red Hat Certified System Administrator (RHCSA) exam, the process to reset the root password in a Red Hat Enterprise Linux (RHEL) is critical for your success, and to be honest, it will save you every single time that you are stuck on a server. The process is simple, and it starts when the system is booting up. When restarting a Linux server, wait for the GRUB menu to be displayed, press e to edit the current version kernel.

Find the line that starts with linux and has /vmlinuz as the second parameter o the same path. Go to the end of that line, and add the string rd.break at the end, and then hit Ctrl-x to break the boot process by intercepting the process before it is moved to the systemd (regular flow).

The following step is not required and not even documented in the Red Hat official documentation. I do use this step to help me to memorize the next steps. Our focus is on the sysroot folder.  Keep in mind that we are breaking the boot process, and we are one step before the systemd.

mount -l | grep sysroot

The sysroot is mounted in read-only mode, which does not help us to reset the password because the changes will not be saved. Our first step is to remount as read and write.

mount -o rw,remount /sysroot

The final step is to chroot jail, which means that we are going to go inside of a box, and everything that will exist for us will be inside of that folder.

chroot /sysroot

Now that we have access to a console. We can go ahead and change the password, and the final step is to add a file .autorelabel, which will instruct SELinux to relabel on the next boot.

passwd root
touch /.autorelabel

Type two times exit, the first to leave the chroot jail, and the second to leave the current rd.break session, which will trigger a restart of the server.

The entire process described in the previous step can be seen in the image below.

And just like that, you have reset the root password.

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides of the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange, CISSP and several other certifications. Anderson contributes to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at Techgenix.com, MSExchange.org, ITPROCentral.com and Anderson Patricio.org (Portuguese).

Share
Published by
Anderson Patricio

Recent Posts

Dell unveils new PCs optimized for remote work

With remote work here to stay, companies are looking to supply employees with devices to…

2 hours ago

Using Azure Active Directory Identity Protection to boost your security

Using Azure Active Directory Identity Protection will boost your security. This step-by-step guide shows you…

20 hours ago

Review: Kemp Virtual LoadMaster load balancer

With many businesses requiring employees to work remotely, Kemp’s Virtual LoadMaster can help relieve many…

23 hours ago

Microsoft warns of COVID-19-related spear-phishing campaign

COVID-19 is not going away anytime soon, and as Microsoft researchers have discovered, neither are…

1 day ago

Ansible: Introduction to this open-source automation platform

In this first of several articles on Ansible, we give you a high-level overview of…

2 days ago

Microsoft Build 2020: All the major announcements

Microsoft Build 2020 may have been a virtual event, but there was some real news,…

2 days ago