If you forgot your password for ubuntu system you can recover using the following steps
Turn your computer on.
Press ESC at the grub prompt.
Press “e” for edit.
Highlight the line that begins kernel ……… press “e”
Go to the very end of the line, add rw init=/bin/bash
press enter, then press “b” to boot your system.
Your system will boot up to a passwordless root shell.
Type in passwd username
Set your password.
Type in reboot
If this doesnt work you can alternatively try this:
Turn on your computer, and as soon as you the Press Esc to enter grub message, press the escape key.
Select the option that says (recovery mode).
Your PC will boot into a shell. Once you get a command prompt, type “passwd username” where the username is your username.
Enter a new password when prompted, and again when prompted again
Type reboot to reboot your system
Another way is to boot into the system via a live cd open up Applications->Accessories->Terminal
then mount your ubuntu drive if its on /dev/sda1 do this:
mount /dev/sda1/ /media/sda1
Then we chroot into the system:
Now change the password, and reboot your box!
source via Ubuntu Unleashed