To reset the root user password, you need to have physical access to the server with a connected monitor and keyboard, or use remote access tools such as IPMI for SuperMicro, iLO for HPE, or the noVNC console for managing our virtual servers.
Resetting the root password in CentOS 7 is slightly different from Ubuntu/Debian.
First, you need to power on or reboot your server.
During boot, you will see the GRUB menu.
Select your boot line. Now you need to press the E key on the keyboard to edit the grub parameters. Then scroll down to the line that starts with linux for 64-bit IBM Power Series, or linux16 for BIOS x86-64 systems, or linuxefi for UEFI systems.
We change the text parameter ro to rw in this line to enable write access to the root file system. We remove the parameters rhgb and quiet , and add rd.break enforcing=0 at the end of the line.
Press CTRL + x to start the system in single-user mode.
Then enter the following commands:
chroot /sysroot
passwd root
touch /.autorelabel
exit
reboot