If you’ve lost or forgotten the root password of your RH/CentOS 7 box, here’s how to reset it.
Reboot, at the Grub menu press ‘e’ before the timeout occurs.
Find the ‘linux16’ line and append the following to the end of it:
Press Ctrl-x to boot with the new configuration. This will boot into a Bash shell as the first process. Your root directory will be read-only at this point, to fix that:
mount -o remount,rw /
Then change the password:
Finally, due to the SELinux policy in v7, you’ll need to do the following:
Then reboot and enjoy!