How to use Knoppix to reset forgotten Linux passwords

From ArticleWorld


There are some occasions when you will want to reset the passwords used by a Linux installation. This is usually the case when you or one of your users forgot a password, or when you receive donated hardware without the account passwords. Resetting the password usually involves editing a single file, and what we cover here is the usage of Knoppix. However, any Linux live CD or floppy distribution will do, as long as it can mount your root filesystem. Here is how to do it.

Procedure

1. Boot the system from the live CD. You may need to change the configuration of your computer's BIOS to boot from the CD. Refer to your motherboard's documentation for details on this.

2. When the computer has finished booting, go to the console. In KDE, this involves opening a Terminal window. If you have another distribution, maybe without a GUI, you get one when the computer boots up.

3. Use mkdir to create a mountpoint for your root filesystem:

mkdir /mnt/mountp

4. Now mount your partition:

mount /dev/[device] /mnt/mountp

[device] should be the device that contains the root filesystem. It should be similar to hdXY, where X is a letter and Y is a number. Look over the Linux documentation if you do not understand the Linux partitioning scheme.

5. Now, using your favorite text editor, and logged in as root, open the /etc/shadow file from the mounted root partition. We show the usage of nano here, since it is small enough to be included with just about any live distro.

nano -w /mnt/mountp/etc/shadow

If you know that you do not use shadowed passwords, open /etc/passwd of course.

6. Scroll through the file until you get to the account whose password you want to reset. For example, supposing we want to reset the password of the user ronnie, we would find the line that looks similar to:

......
ronnie:fdOfaEtREioptEQ:14311:0:99999:2:::
.......

The first sequence of letters (fdOfaEtREioptEQ) is the encrypted password. Simply remove it and leave everything else intact.

7. Save the file. Unmount the filesystem you mounted earlier and reboot from your hard drive. The account will no longer have a password, but do make sure to change this.