Note: Incorrectly editing any of the files in the /etc/ directory can severely screw up a system. Please keep a spare copy of any files in case you make a mistake.
If your Linux distribution permits, try booting into single-user mode by typing "single" at the BOOT lilo: prompt. With more recent distributions, you can boot into single-user mode when prompted by typing "linux 1," "linux single," or "init=/bin/bash."
If the above doesn't work for you, boot from the installation or rescue floppy, and switch to another virtual console with Alt-F1-- Alt-F8, and then mount the root file system on /mnt. Then proceed with the steps below to determine if your system has standard or shadow passwords, and how to remove the password.
Using your favorite text editor, edit the root entry of the /etc/passwd file to remove the password, which is located between the first and second colons. Do this only if the password field does not contain an "x," in which case see below.
Change that to:
If the password field contains an "x," then you must remove the password from the /etc/shadow file, which is in a similar format. Refer to the manual pages: "man passwd," and "man 5 shadow."
[Paul Colquhuon, Robert Kiesling, Tom Plunket]