Resetting the password in CentOS 7.x system

Resetting the password in the CentOS 7.x system can usually be done automatically by accessing the backend. However, in case of special circumstances where this method is not feasible, you can follow the manual steps to reset the password.

 

1.Firstly, restart the machine and access the boot menu. Press "e" to edit the currently selected kernel.

 

 

2.Scroll down the list until you find the line with an underscore (_) below the "ro" parameter.

Change "ro" to "rw" and add "init=/sysroot/bin/sh" at the end of the line.

 

 

3.After making the changes, press Ctrl + X to boot into single-user mode with the specified bash shell. In this mode, we will change the root password.

  • rw init=/sysroot/bin/sh 

 

 

4.Once in single-user mode, run the following command to change the root password.

  • chroot /sysroot 

 

 

5.Lastly, run the following command to change the root password.

  • passwd root  

 

 

6.The system will prompt you to enter and confirm the new password. After creating the new password, run the following command to update SELinux parameters.

  • Touch /.autorelabel 

 

7.Finally, exit and reboot the system. You can now log in using the new password.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

CentOS 7.x Firewall: Enable/Disable and Add Ports

  In CentOS 7.x, the default firewall is firewalld. Here is an example using CentOS 7.6...

How to enable/disable ping on Linux system

To prevent others from discovering and potentially attacking your machine through network ping...

How to View Memory Usage and Clear Cache in Linux System

Sometimes, when a server becomes unresponsive, it may not necessarily be due to high CPU usage....

How to remotely access a Linux system using Putty tool

Introduction to Putty software PuTTY is a Telnet, SSH, rlogin, raw TCP, and serial interface...

Linux System RuiSu Installation Tutorial

Note: The prerequisite for installing RuiSu is to ensure that the network card is in the "eth"...