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:
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
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
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:
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! (^)__(^)