Boot from the installation disc (or use any other live-cd Linux distribution), then mount your on-harddisk Ubuntu's root partition, edit there /etc/shadow and empty root user's password field (first field is username, then comes field separator which is :, then comes password field, then field separator :, ...) Save the file and reboot as you usually would - if you did it right, you should now be able to login as root without a password (because it was set blank).
Mounting a partition (assume first primary harddisk partition to be sda1 and mountpoint /mnt):
Code:
sudo mount /dev/sda1 /mnt
Then edit the file:
Code:
sudo gedit /mnt/etc/shadow
In the shadow file are stored user/password information, one row per one user. Here's an example of the root user's line (usually first):
Code:
root:!:13970:0:99999:7:::
First field says "root", second "!" and so on. Second field is the (encrypted) password which you'll want to empty so it becomes like this:
Code:
root::13970:0:99999:7:::
Note that here the password field contained only "!" which is not acceptable char in the password; this means that the account is "locked" and you can't log in as root (default Ubuntu way -- you're supposed to use sudo instead). If you have set up a root password, instead of the exclamation mark the field contains a longish gibberish string which is the encrypted password.
With root account open you can then use passwd to reset other accounts' passwords if you need.