If you forgot your ubuntu user password,or you have enabled root user and forgot the password,you can try following to reset the forgotten password.
First,start your machine and when it boots into grub menu,select “Ubuntu GNU Linux …. (recovery mode)” (just use up/down arrow key to highlight it,not press enter).
Press E to get into edit screen,there find ro single and change it into rw single init=/bin/bash,then press Ctrl+x or b to boot into a command line.
type following command:
mount -a passwd your-user-name
it will prompts to input new password.If you want to reset the root password,change the second command to passwd root.
Now,restart and login with the new password.