How to recover the root password in Debian 6 and RHEL 6 based systems …
On a Debian based system it something like this:
On the boot menu (GRUB Boot loader) select the first line and hit “e”
edit the line starting with:
linux /vmlinuz …
go to the end of the line and edit it so it looks like this:
rw init=/bin/bash nomodeset
hit CTRL +X
You are in!
Now just use the passwd command to change root’s password.
If its RHEL based system it changes a little bit:
At the boot menu (GRUB Boot loader) type: “e”
Edit the kernel parameter line, you know the one with the “/vmlinuz” in it.
Change the ro (read-only) for rw (read-write) and add the capital letter S and hit ENTER to accept the changes.
Next hit b (boot) and wait for the system to boot.
Once you are in the system RHEL probably has SELinux running, you have to disabled it for the password change to be accepted. to check SELinux run sestatus and to change it execute “setenforece 0″
Finally you can change the password using the passwd command.
Hope you find this useful.