Sometimes you need to reset root password from a Centos 7 system.
Here I will show an easy way, not the only one.
First you’ll need access to grub boot screen, if system it’s running you can send an Ctrl+Alt+Supr key combination
at this point we can press the key e to edit boot sequence
we need to move down to the line linux16
we should append rd.break at the end of line
and press Ctrl+X to boot with line modifications.
If we edit all correctly we will have a shell in emergency mode
in rescue mode mount point / can be accessed under /sysroot directory, but it’s on readonly, we need to remount with write permissions.
mount -o remount,rw /sysroot
afther this we will do a chroot in this dir to access to all commands
chroot /sysroot/
now we can change root password executing
passwd
finally we need to force our system to relabel selinux file context because in emergency mode selinux it’s not enabled
touch .autorelabel
finally we need to exit from chroot
exit
and reboot our system to make a normal boot
reboot
now you should have root access using edited password