Reset lost root password and more using Knoppix (Linux live CD)

Whew….It’s been a while since I’ve weblogged something. Grades have gone up and down, exams have come and go (and they’re still coming btw).

What happened was I needed to replicate a setup (my thesis actually) on an all-in-one-PC (very similar to this one though with only 512 MB of RAM). I installed Arch Linux (for reasons I hope I’ll be able to weblog about sometime soon) and I forgot the root password after I installed it. It was a careless move and I should have backed the root password up after setting it (by sending an e-mail to myself for example).
Here’s how I reset the root password:
Firstly, there are a number of different ways to do this, but what I’ll be using is a live Linux CD. You can select a number of them here, but I personally prefer Knoppix, which I also think is the best all-around Linux live CD. I’m currently using the 5.1 version of Knoppix, though I think this will work even if you use the 3.x versions.
Secondly, we proceed to the resetting proper.
1) reboot the PC and boot from the Knoppix CD.
2) Usually, the default language of Knoppix is US-English, but if you boot it and it doesn’t appear to be so, enter this at the boot prompt:

knoppix lang=us

then hit enter
3) you can actually not boot a GUI (such as KDE or fluxbox) but in case you do, this will still work nonetheless.
4) open a terminal/console and type


so you can get root access
5) create a dummy directory which we’ll use to mount the partition where you installed the Linux OS which you want to reset the password to. In this case I enter

 mkdir testdir

6) enter

 mount /dev/hdaX testdir

if your hard drive was scanned as an IDE hard drive or

 mount /dev/sdaX testdir

if it was scanned as a SCSI drive. X represents the partition number of the drive where the root password, and hence, the


is installed. This assumes that sdaX or hdaX includes the file you want to edit, in this case the file which contains the root password you want to remove/change.

7) change to the


directory by entering

 cd testdir/etc

8 ) use a text editor such as




to open the


9) Once you open the file


go to the line entry with


in it. It should look something like this


10) Delete everything in between the first and second colons, so that the entry will look like this


11) save and exit your editor
12) change to your home directory, for example enter


13) unmount the partition:

umount testdir

14) enter


to reboot the system and remove the Knoppix live CD.
Now you can login to your system as root without any password to begin with! Make sure to do


asap to change the root password!

Using the same principle, you can verily see how easy it is to edit other system files when something happens to your machine, be it a Linux or a Windows machine. You can edit (in Linux) your resolv.conf, fstab, and a lot more using this technique. That’s why I always keep a live Linux CD around! (^)__(^)

About these ads

10 Responses to “Reset lost root password and more using Knoppix (Linux live CD)”

  1. waldemar Says:

    You can also reset the root password in another way provided that your boot loader is GRUB. As far as I can remember, you only need to append “single” to the kernel parameter. Then, it will boot into single mode which is like a limited shell environment with root as the user. You can now change the password by issuing the passwd command.

  2. f241vc15 Says:

    Yep sir Waldemar (^)__(^) I’ve read also that you can append the ‘single’ parameter when using GRUB. I also remember adding another ‘init=/bin/bash’ parameter before the ‘single’ one if in case the system asks for a root password still. Unfortunately (don’t know why or how as of now) it didn’t work for me. The kernel panicked. Any clues to this?
    Finally, I still carry around my trusy Knoppix live CD in my Echolac backpack just in case somebody’s PC (whether Linux or Window$) needs any help (^)___(^).

  3. Recover root password in linux « /home Says:

    [...] Link 1 [...]

  4. Baipievegrike Says:

    Various of guys write about this subject but you said really true words.

  5. Root password Says:

    [...] Check this one…linux-live-cd/ [...]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: