Recovering Root Password

If you forget your root password, you can easily reset it by entering some options into grub loader when system is being loaded. After system reset, and some bios check, Grub is loaded and there are some choices from which kernel or operating systems to boot.

Debian GNU/Linux, kernel 2.6.18

Press ‘e’ to enter edit mode.

root(hd0, 2)
kernel /boot/vmlinuz-2.6.18 root=/dev/hda3 ro
initrd /boot/initrd.img-2.6.18
savedefault

Select kernel option and press ‘e’ key again to edit kernel options. Add init=/bin/bash at the end of line such as,

grub edit>kernel /boot/vmlinuz-2.6.18 root=/dev/hda3 ro init=/bin/bash

Press enter to return back and press ‘b’ key to boot kernel with these options. System will boot and eventually /bin/bash will run without asking password to login to the system.

mount -o remount, rw /
passwd
Enter new UNIX password:
Retype new UNIX password:

After you change your password successfully, you can “reboot” system normally to use new root password.