If you ever get locked out of your Ubuntu installation as I found myself to be tonight, you can reset your password quite easily using the following steps.
- Power up your computer.
- Press ESC at the grub menu.
- Press e for edit.
- Highlight the line that begins “Ubuntu, KERNEL ………” and press e.
- Go to the end of this line, add rw init=/bin/bash and press enter.
- Press b to boot your system.
- Your system will boot up to a passwordless root shell.
- Type in passwd username where username is the username you lost the password for.
- Set your password.
- Type in reboot.
That is it! you can now log in using your new password. You can even reset your root password here but cannot login with it at the login screen.