Open In App

How to reset the root password of RedHat/CentOS Linux

Last Updated : 30 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

RedHat Linux is a worldwide used OS in servers and networking devices. Red Hat lists Adobe, Ampersand and many among the top 500 fortune companies. They list Cisco, Dell, HP, and IBM as partners. Resetting the root password of RHEL is not a difficult task but rather you need to know 4 commands and you are into the root account!
Root account in Linux is that user which has unlimited power in Linux without any restrictions. This article revolves about how one can reset the root password of RedHat/CentOS Linux. We are working here with the latest version of RHEL which is RHEL 8.

STEP 1: Start your OS and you will see this screen as soon you start your OS.

Press e, a new screen will come as shown below.

The place where green arrow is there, type

rd.break enforcing=0

.
Press Ctrl+X to continue that process.
When BIOS loads up your OS, in between that rd.break will stop that process there and enforcing will stop the security of RHEL which is SELINUX from any intervention.

STEP 2: you will get this screen like shown below

You are in Emergency mode now. This is the main screen and most of the work will be done here.
command 1:

mount -o remount, rw /sysroot/

command 2:

chroot /sysroot/


Type

passwd root

and enter the desired password twice.

>you will get a bash shell from where you can change the root password as per your own choice.The command for changing password in Linux is passwd username. now type

exit

twice.
Congrats, you have successfully changed the root password of RHEL without any intervention of SELinux(Security-Enhanced Linux) and you can login into root account with that password.
But wait, after logging in the SElinux becomes active again and encrypts your /etc/passwd file which is a highly secured file where all users and link to their passwords are kept.

STEP 3:So, a last command to decrypt that file
command 3:

restorecon /etc/shadow

.

Follow all the steps in order explained and you will be easily able to reset root account password.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads