Skip to main content.
Friday, December 23rd, 2005

Reset root Password in Linux

Did you realize it could be done? I didn’t. When I just now tried to log in as root, I was confronted with my stupidity when I found that I must have changed it and couldn’t, for the life of me, remember doing it, let alone what it was. I had visions of having to reinstall Fedora Core 4 and starting all over again. So I Googled reset root password and got the answer with the first hit.

My FC4 grub entry reads like this:

root (hd0,1)
kernel /vmlinuz-2.6.14-1.1644_FC4 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.14-1.1644_FC4.img

Which is pretty standard. My FC4 root partition is the second one in my hard drive, and I’m using the latest kernel. Then I used the command line and entered the following (showing the prompts):

grub> root (hd0,1)
grub> kernel /vmlinuz-2.6.14-1.1644_FC4 root=LABEL=/ single
grub> initrd /initrd-2.6.14-1.1644_FC4.img
grub> boot

I had problems with “File not found” showing after typing in the kernel name, so I actually used Tab to get the filenames available.

This booted me into a command line interface as root. I typed in “passwd” and was prompted to enter a new password, then retype it again for confirmation. I hit CTRL-ALT-DEL to reboot, selected FC4 in my grub, and I was able to log in as root using the new password. Amazing!

I guess this is why you get those strongly worded recommendations to use a bootloader password when you’re installing grub. That doesn’t work for me at home because the wife and older kid would whine about having to enter any passwords, and the baby has a habit of pushing buttons, so he often reboots the computer for us. (I got a case with a clear plastic front door, but I had to put little stick-on plastic feet on both sides of the power and reset buttons because you could push them through the plastic – I still need to find some sort of lock, though.) My grub is set to automatically boot to Windows XP after eight seconds, and I don’t think anybody understands the concept of multiple operating systems.

Posted by Greg as OS at 05:06 PST

Comments Off on Reset root Password in Linux