To reset root password we have to boot into single user mode.
1.Interrupt the computer while booting at GRUB.
2.Type ‘a’ to append kernel argument or ‘e’ to edit.here we can type either ‘a‘ or ‘e’
3. Type 1 or single selinux=0 to disable selinux(if required) at the end of boot arguments and press Enter to boot into single user mode. for example single selinux=0 or 1 selinux=0
4.Now your system will boot into single user mode. to Check the runlevel type runlevel command.output will be like ‘1 S’ ie single usermode.
5.Now Type passwd command and change you root password.
6.Once you change you password reboot the system or type init 6 to reboot or init 5 to boot to Full multi-user GUI mode login.we also use telinit runlevel command to boot into a particular run level.
# 0 – halt
# 1 – Single user mode
# 2 – Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 – Full multiuser mode(Text Console ie without GUI)
# 4 – unused
# 5 – X11 (Multiuser Mode but with single GUI ie only one user can access GUI at time)
# 6 – reboot
the above runlevels can be found in /etc/inittab file.