You can recover/reset/change your root password on Ubuntu if you have physical access to the machine following these simple steps.
- Reboot Ubuntu.
- At the GRUB menu press ‘e’ (with quotes), which will let you edit GRUB.
- Edit the line with your boot command.
- Add this command to the very end of the line with the boot command:
rw init=/bin/bash - Press enter and boot your system, the command, “rw init=/bin/bash” will make your Ubuntu boot with passwordless root shell.
- Once you’re logged on just change your password with the passwd <username> command. If it is root just type: passswd root.
- Reboot your system.