How to reset forgotten root password on centOS 7/RHEL 7

0
635

Sometimes we forget some important stuff like keys, meetings, passwords etc. But, if we forget server passwords that going to be a serious problem. In this article, we will be known about the resetting of forgotten root password on CentOs 7 and RHEL 7.

 

For this first restart the system and press arrow keys on keyboard to interrupt the boot.

select the Linux kernel and press e key to edit the boot parameters.

Now find the line start with linux 16.

At the end of the line add rd.break

Now press ctrl+x to start. Now the emergency shell is starts like as follows

Now Mount /sysroot/, By default /sysroot/ is mounted in read mode. so remount it in read and write mode.

Now apply chroot command on /sysroot/.

change the password by using the passwd command as follows

now run the command touch /.autorelabel and exit command.

reboot the system by using reboot command.

Enjoy the system with new password.