You are here

How to Reset Root Password in CentOS 6 and CentOS 7: A Step-by-Step Guide


How to Reset Root Password in CentOS 6 and CentOS 7: A Step-by-Step Guide

Carrying forward from our previous discussions on CentOS, this comprehensive guide will walk you through the process of resetting the administrator password in CentOS 6 and CentOS 7.

Getting Started with CentOS 6 Password Reset:

Reboot Procedure:

Start by rebooting your computer. During the boot-up phase, when prompted, press the indicated button to enter the Grub menu.

entering any key to get in the grub menu

If you have multiple kernel images, choose the latest one and press the 'a' button.

grub menu

Editing Boot Parameters:

Once in Grub, navigate to the boot line. Remove "rhgb quiet" if present and add "single" for the reset procedure.

editing boot parameters for centos system in the grub menu

editing boot parameters for centos system in the grub menu

Resetting the Password:

Press enter to boot in single mode. Now, simply type passwd, set your new password, and reboot the system. Congratulations, your CentOS 6 password is now reset!

reseting password in centos 6

CentOS 7 Password Reset: A Different Approach:

Starting the Reset Process:

Reboot your CentOS 7 system and access the boot menu. Select your desired image and initiate the reset process by pressing the 'e' button.

grub menu in centos 7

Parameter Adjustments:

In the parameter editing section, adjust the necessary lines. Especially focus on the line starting with "linux16." Modify the "ro" parameter to "rw" and append "init=/sysroot/bin/sh". Finalize with ctrl+x.

editing boot parameters in grub for centos 7

editing boot parameters in grub for centos 7

Final Steps:

Post-boot, use the commands chroot /sysroot followed by passwd to set your new password. Finish up with the commands touch /.autorelabel and exit. Reboot, and your CentOS 7 administrator password will be successfully changed.

reseting password in centos 7

Conclusion:

Resetting admin passwords in CentOS doesn't have to be daunting. With these simple steps, you can easily regain access to your CentOS 6 or CentOS 7 systems.

Additional Resources:

0 0

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<