You will need to boot into single user mode and remove the root password. Then
you can boot normally, become root, and reset your user password. Detailed
instructions below courtesy of
http://www.linuxclues.com/articles/11.htm
By booting with your rescue CD (or to a live Linux CD, such as your original
Ubuntu install CD or Knoppix), you can bypass Step 1, mount the partition and,
while logged in as root, skip right to Step 2 and make the changes to the files
Step 2 requires.
Step 2
After following Step 1 as appropriate, type the following at the prompt:
# cd /etc (For Knoppix, first you must change directory to the partition with
your lost-password distro.)
Step 2 requires you to make changes to these two files: "passwd" and "shadow."
Type this line:
# vi passwd (This opens the file with the Vi editor.)
Next, press the I key, which places the Vi editor in Insert mode.
For more on the Vi editor, see the Vi Editor edition of Tips for Linux
Explorers.
The first line of the passwd file will probably look like this:
root:x:0:0:root:/root:/bin/bash
Carefully delete the "x" after "root:" being sure to leave the colons in place.
The first line should now read:
root::0:0:root:/root:/bin/bash
Save the file by pressing the Escape key and then typing:
ZZ
To edit the second file, type:
# vi shadow
Press the I key to place the Vi editor in Insert mode.
The first line of the shadow file is a long scrambled string of characters.
Change it to:
root:::: (That's four colons.)
Save the file by pressing the Escape key and then typing:
ZZ
Now you can reboot your computer. Log in as your normal user, open a console,
and type:
$ su
# passwd
And set the new root password. Log out as root:
Ctrl-D
And the job is done!
Congratulations! You've now reset your lost password. You should plan on never,
ever going on another extended vacation again (or getting older, or having kids,
and so forth) -- so this will never happen again. After all, there's nothing
more important than Linux. Right?