Sunday, January 4, 2009

Reset old root passwd with chroot

For at least 2 years, I did not need to transform myself to become superuser, root. Sudo is fit for everyday admin's works and Linux is very stable. (As you know it) Hence, I hardly need to configure anything new. New year has come and I wants to update and clean up things. And the most graceful amenity way to do things is to become the superuser. However, at that moment, I found out that I forgot the root passwd! 1..2..3.....10.....15 tries, ahh..without sucess. Enough is enough. Let's reset the old passwd!

Rebooting the system with a bootable CD. (Here, I did not know where I did keep my Debian CD, I didn't use it for ages. I searched around and ahh..I still have KNOPPIX CD.)


After rebooting the system, at the command prompt, let's create temporary directory mount point.
#mkdir /mnt/hda3

Mount the partition, in my case it locates at /dev/hda3.
#mount -t reiserfs /dev/hda3 /mnt/hda3

Here comes the chroot in action:
#chroot /mnt/hda3

You may be able to see your root shell path changed. Ok, we now call the "passwd" command, the shell will not ask for old passwd but allow us to enter new passwd straightaway. Reboot and remove your bootable CD. Done.

-----------------

"With Great Power, Comes Great Responsibility." Uncle Ben to Peter Parker in Spider-Man. I came upon this quote the first time when I first tried "sudo".