Linux Administration: Resetting the root password when forgotten.
So you've lost the password to the root account. Worst, you've had a boot password and it was the same. Here are some instructions on how to get back into your system:
Create a user on another Unix / Linux operating system.
# useradd resetrootpass
then set the password on the new user:
# passwd resetrootpass
once password is set, edit the /etc/shadow file and copy the encrypted password text:
# cat /etc/shadow
resetrootpass:$1$4K5.hqbH$lKPzvk8qbmBaK9TJi0p0:11675:101:88888:3:::
to the /etc/shadow root's password field on your OS where you've forgotten your password too (You may need to use a boot CD like a Linux Live CD to mount the system with then mount the partition to get access to the /etc/ folder).
Once you replace the root's encrypted string with the new one you created above for an arbitrary user, you should be able to boot and login with the new password.
Cheers!
TK