Changing password normally
The first way to change your password in Ubuntu is to use the command "passwd." Fire up the Terminal and enter the command
and press enter. It will prompt you for your current password. Enter the current password and press enter again. it will now prompt you to supply the new password and once you enter the new password you need to confirm it by retyping it. Press enter after you retype the password and, if you have done everything correctly, your password would be changed to the new password you supplied.
If you don't like using the terminal, don't worry, you can change your password without using the termina,l too.
Navigate to the System → Administration menu and click on "Users and Groups." This will bring up the "Users Settings" dialog. Here you can see a list of users including your own. However, you can change password only for your own account (obviously). Select your user name and click on Properties or just double click on your user name to bring up the properties window. In the properties window you can set up various properties related to your user account like user's real name, contact information, etc. You can also change your user password here. Select the option "Set password by hand" to set up your own password. Type in the new password and confirm it by retyping it in the box below. Click OK and you're done. if you don’t want to set your own password then you can select the option "generate random password" which will automatically generate a random password for you.
Resetting your password if you've forgotten it
Reboot your system and while you see the message "Loading GRUB" press the ESC key. In the GRUB prompt, you'll see a list. Select the one that has a "recovery mode" in the end. Press enter. It will take some time till your system boots into a shell. Once the shell is available, type in
In case you've forgotten your user name too, just type in ls/home to find it out. Enter and confirm your new password when prompted and after changing your password reboot your system. Now you should be able to login using your new password. (Though this trick works nicely with older version of Ubuntu I have not tested it with the latest Ubuntu release.)