Reset a forgotten root password

It doesn’t happen very often but it can happen so here’s what to do in case it does. What am I talking about? I’m talking about forgetting your root password. The root or the superuser password is like a key to any part of your system. So what happens when you lose this key? Nothing… You just follow the steps given below 🙂

The next time you boot give ‘init=/bin/sh’ as an argument to the kernel, and reset the root password with the ‘passwd’ command.

For lilo, at the prompt type ‘linux init=/bin/sh’, for grub, hit ‘e’ when you have selected the right entry in the menu).

Or easier perhaps, boot with a linux live-cd or a rescue cd, look for the partition in which your etc/passwd file is (fdisk -l should give you insight into your partition table), and reset the root password by:

mount /dev/hda1 /mnt

(assuming the first partition on the first ide disk is your root partition, try hda2, 3, etc if the next step fails)

chroot /mnt

Reboot your PC


About synapse
Programming, motorcycles and photography. Want to do more, but only have time for so much!

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: