25th April 2024

How to Change Root Password of CentOS 7 on VMware ESX?

In this article, we will talk about how to restore a forgotten or lost root password on Redhat and CentOS 7 operating systems. We will be explaining these processes on CentOS 7. Because we forgot the password of CentOS 7. These operations are also valid on RHEL. First, if our server is open, we restart it and click the “e” key when the boot screen comes up.

 "e" key
“e” key

 

We find the line starting with Linux16. We come to the place where it says “ro”.

ro
ro

 

We delete the “ro” and write the line “rw init=/sysroot/bin/sh” instead.

rw init=/sysroot/bin/sh
CTRL+x "rw init=/sysroot/bin/sh"
CTRL+x “rw init=/sysroot/bin/sh”

 

Then we click the “CTRL+x” ​​key to switch to recovery mode. We run the commands below in order. You can set our new password after typing the “passwd root” command.

chroot /sysroot
passwd root

touch /.autorelabel
exit
reboot
new password
new password

 

After running the reboot command, the SELinux relabeling process starts and may continue for a while depending on the state of your system. After the process is finished, our server will restart. Then we can login with our new password.

login with our new password
login with our new password

 

LEARN MORE  What is ping command?

Leave a Reply

Your email address will not be published. Required fields are marked *