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

How to switch to a different repository for CentOS 8 EOL

 CentOS 8 reached its end of life at the end of 2021. When using yum repositories for...

To change the network interface name in CentOS 7.x

一.modify GRUB 1.Edit the GRUB configuration file by running the command: `vi...

To modify the hostname on CentOS

Method One:   1.Open a terminal or SSH into the Linux system. 2.Log in to the system with...

An incorrect configuration in the /etc/fstab file on the Linux system is causing login issues

Encountering communication issues with the machine, I checked the system error messages through...

How to use the atop monitoring tool in Linux

Atop is a monitoring tool used to monitor resources and processes in Linux systems. It...