Here's a generic answer valid for each distro around.
Start your PC with a livecd distro, everything carrying a text editor is fine. Now from command line or XWindow start a terminal.
If you don't know the name of your root partition you need to discover it, type: "fdisk -l" to list all available partitions (mounted or not) in your system, than try to locate your root partition (should be somethin like /dev/sda2 /dev/hda2 or something like that)
now mount your root partition in your current live tree, assuming you've discovered /dev/hda2 as your root: mount /dev/hda2 /mnt. Please note your /mnt should exist before this operation or create a new different dir (example /tmp/myrootdisk); if you've a readonly file system try to create a dir into /tmp, it works most of the times.
Now edit your shadow file where password resides, assuming you've mounted your root disk into /mnt you'll have the file in /mnt/etc/shadow
Inside it you'll have lines like:
now with your favorite editor (vi, nano, mcedit, ...) delete the string between first and second ":" for the user you want to modify so after your edit it will look like:
and save the file when finished
If your system allows you to log in as root you only need to change the line where the root user is reported, if you've something like ubuntu configured for denying root user login you need to edit even your common account (if you don't remember that password too of course). Than you're set.
Take off the live cd and reboot the machine, now when trying to access common user or root you've an empty passwd.
This method works if
- You're using shadow passwords, if you're using traditional passwords based on /etc/passwd you need to edit that file
- You're not using an encrypted file system. If you've encrypted root filesystem when you've installed your linux distro you need to remember a password to access it or the root partition is totally scrambled and you're in serious troubles (encryption is made for this)
If you're still reading this long post if you need more info please let me know