There are many ways to reset your forgotten root password. Following are some that I have tried.
Using RHEL Boot CD
The one that I normally go for is by using an alternate boot medium. It may be usb or a cdrom that can be helpful. Many systems these days provide usb booting option. Well we will go for the other one that is cdrom. We just have to make our system ready to boot from the cdrom and this can be done in the BIOS settings. I wont go much into details of BIOS, you will find plenty of material available on the net to do so.
Boot by cd1
Press F5 for rescue mode
Type linux recue at boot:
Choose continue to mount the linux partition on /mnt/sysimage
Finally it gives you a shell prompt
type # chroot /mnt/sysimage
Now you can edit the /mnt/sysimage/etc/shadow file through vi editor
# vi /mnt/sysimage/etc/shadow
Cut out the password from the password field from root in shadow file, save the file and reboot the system.
This will give a passwordless root account.
Using GRUB Menu
At GRUB Boot screen, hightlight the kernel image and press 'e'.
Then press 'e' at line starting with “kernel”.
Give space and type single or rw single init=/bin/bash
Hit enter & then press 'b' to boot the system.
The system will boot to passwordless root shell.
And we are done
Using Ubuntu 10.10 Live CD
Boot the system using Ubuntu 10.10 Live CD.
Open a terminal.
Type # sudo fdisk -l to know your root partition.
In my case it was /dev/sda2. After you get to know your partition, type
# sudo mount /dev/sda2 /mnt
Then we have to make /mnt as our /.
# sudo chroot /mnt
Finally change your password
# passwd root
Or we can also go for editing /etc/shadow instead of passwd command
# vi /mnt/etc/shadow
# sudo mount /dev/sda1 /mnt
Or, we can edit the /etc/shadow file using any editor that you are comfortable with. I had used nano editor.
Using GRUB Menu
Find the line starting with 'linux' and replace 'ro' with 'rw' and append init=/bin/bash at the end of the line.
Here too we can go for editing the /etc/shadow file through any editor you like in case the passwd doesnt work.