Reset root password on CentOS

In the GRUB menu, select the kernel to edit and press e.

Go to the line starting with linux16 and replace ro with rw init=/sysroot/bin/sh. Press Ctrl+x to boot in single user mode.

To access the system type chroot /sysroot.

Use passwd to change root password or pam_tally2 to unlock the account.

Exit and reboot.