If you lost your root password and wants to reset it, here is the easy way. Follow these steps.
1.After you switch on your computer, select the operating system (Linux) whose root password has to be reset from the grub.
2.Press ‘e’ to edit in the boot option.
3.Now move the pointer to the line where the kernel’s name is mentioned.
4.Go to the end of that line by pressing ‘end’.
5.Add the following line to it.
single rw init=/bin/bash
6.Press cntrl+x or F10 to reboot the system. (It can change on different versions)
7.Now in the black screen that appears, change the password of the User or root with the following command.
$ passwd user
Then enter the new passwords when prompted for.
8. Enter $reboot.