It's a common case that when you have not used your Ubuntu machine for some time you may have forgotten your password.
If you want to reset a new password instead of your old one,
and don't want to loose any of your date this is the coolest way to do.
But for this your computer need to have a CD ROM and you need to have a Ubuntu Live CD with same(preferred) or fairly close version.
Insert the Live CD and boot the computer in the Live CD mode.
Open the terminal and change to the root user
sudo suStep 3.
create a directory
mkdir fooStep 4.
Find your Linux partition.
e.g. using the command
fdisk -lby this you will get all the partition in the computer, and by looking at them you can find out your Linux partition.
Device Boot Start End Blocks Id System /dev/sda1 * 1 18710 150288043+ 83 Linux /dev/sda2 18711 19457 6000277+ 5 Extended /dev/sda5 18711 19457 6000246 82 Linux swap / Solaris
here the Linux partition is /dev/sda1
mount the partition the the newly created file.
mount /dev/sda1 foo/
Use chroot to access the partition as its root
chroot foo/now you have all the root permission to the mounted hard-disk partition.
Use the file etc/shadow to find out the users of the system
e.g. if the user name is bar,
use the commands
passwd barto change user password
passwd rootto change the root password
that's it! all done.
Now restart the computer and login to the system with the new password.