If you forget or somehow manage to change the root password on a machine running various flavors of glibc based security, and you are running a Linux kernel here are the steps to reset it.
-  Reboot the machine. This assume physical access, but reset the root password requires that anyway.
- At the GRUB prompt select the kernel you want and hit ‘e’ for edit.
- At the end of the kernel boot parameters add the word ‘single’. This means boot into single user mode, and should bypass the need to type in a password.
- hit ‘b’ to boot.
- Once a Command prompt appears, use the passwd utility to reset the machine.
- Reboot. Or, you can type ‘init 3’ or ‘init 5’ to complete the bot process. Use 3 for servers, 5 for machines with graphical displays.