How to reset and change the RHEL root password

It takes just a few steps to reset and change your root password in Red Hat. The change can be made directly in the shell using the passwd command. Not only is the strength of the new password important, but also the usage behavior as root. This account should only be used for administrative tasks.

What is the root account and its functions?

The root password is crucial for Red Hat Enterprise Linux (RHEL) as it safeguards the root account, which is essential for maintaining the system, installing packages, updating the package manager, and performing other administrative tasks. Since the root user has unrestricted access to the entire system, the password should be highly secure and used solely for administrative purposes. Consequently, you will be prompted to create a root password at the start of the installation of RHED 9. This password contains at least six characters, should be easy to remember and yet strong enough – check out our guide to password security.

While the initial setup is straightforward, you might wonder how to reset and change your root password for RHEL at a later date. This might be necessary if the previous password is no longer secure. Given the critical nature of this password, the process involves several steps, but it can be completed relatively quickly. We will guide you through the entire procedure.

Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flexibility with no minimum contract
  • 24/7 expert support included

Using the passwd command in the Shell

You can change the root password directly via Secure Shell (SSH) or the console. The appropriate command for this process is passwd. To change the root password for RHEL, use the following command:

sudo passwd root
bash

How to change the RHEL root password step by step

  1. The first step is to log in to your RHEL 9 server. We will use SSH for our example:
ssh username@servername
bash

You must change the user and server name according to your settings.

  1. Then apply the passwd command as shown above:
sudo passwd root
bash
  1. Now, enter your previous password after the line [sudo] password for username:. “username” again acts as a placeholder.
  2. You will then be asked to enter your new password after the line New password:. This must be different from the previous root password for Red Hat but should also consist of different numbers and letters in upper and lower case.
  3. Now repeat the new password after Retype new password:. The change will only be accepted if both passwords match. Upper- and lower-case use are important for this. If unsuccessful, the system will prompt you to try again. If the process was successful, the new password will be used.

As soon as you log in to the server again with your root account, you can use the new password. To do this, use this command to switch to your preferred server:

ssh username@servername
bash

Then use the following command to access the root account:

sudo -i
bash

Only use this account if you really need to perform administrative tasks. For all other areas of application, it’s better to use a different user for security reasons.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top