Ok, so I always keep forgetting the several passwords of my installations on VirtualBox.For keeps, this is how to recover the password for Ubuntu.
1) Reboot the Virtual Machine: Machine >> Reset and quickly press the ESC key while GRUB is loading....refer to below screenshot.
2) Use your cursor to select the line with (recovery mode)... and press the ENTER key. After it loads, it should look like this:
3) Use your cursor to select the line with : DROP TO ROOT SHELL PROMPT, and if you have a maintenance password, you can use it here:
thats all folks.
And just in case you have forgotten the root password all together, then the above step will not help you.
4) Reboot the Virtual Machine: Machine >> Reset and quickly press the ESC key while GRUB is loading....select your regular boot kernel option (usually the default). Make sure the "row" is selected then then use the "e" key to choose to edit that boot option.
Before pressing "e"
After pressing "e". The highlighted line is very necessary in the next step.
Use your up/down cursor to scroll down to the line similar to the above, higlighted in RED.... with linux /boot/vmlinuz-..........at the end of which you would see "ro quiet splash" part.
Use your left/right arrow to scroll to the right and delete the "ro quiet splash" part and then add the following onto the end of the line.
After deleting and updating the line with correct information, it would look like this:
Press F10 to boot, and when the system completes, you can see a command prompt:
HOW TO CHANGE THE ACTUAL PASSWORDS
1) passwd <username>........
After changing the password, use the following commands to reboot your server.
sync :writes the data
reboot -f :reboots the machine
After the reboot, you should be able to login