First step: When you start the Grub menu, press E to enter edit mode ...
Step Two: Locate the Linux 16 line and change the RO to RW init=/sysroot/bin/sh
Step three: Press Ctrl+x to start with single user mode
Step Fourth: You can use the following command to access the system
Chroot/sysroot
Fifth Step: Reset Password
passwd Root
Sixth step: Update system Information
Touch/.autorelabel
Seventh Step: Exit Chroot
Exit
Step eighth: Reboot your system
Reboot
You can change the CENTOS7 root password after a few steps above.
As for CENTOS6 and Rhel6, it's easy to mention (6 and 7 are not the same way to retrieve the password)
Also, when you start grub, press E into edit mode to find quiet to add single or number 1.
Press ENTER,
Then you'll go back to Grub's interface by pressing B. Enter Single user mode
Typing passwd root can modify the password
And then typing the reboot command to reboot the system,
Just typing a new command.