Forgetting the Root Password
If you forgot the root user’s password, it is not the end of the world. There are two ways to reset your root password, and I will go with the easy one. First of all you need to reboot your computer. When you see a countdown timer, hit the key that is written on the screen - for example “Hit Esc to enter menu." After that type linux single and hit Enter. You will access the root prompt and you can set your new password by issuing the passwd command and change the password to your liking.
If this does not work, we have another trick. Issue the vi /etc/shadow command at the prompt. You will see the users and their passwords on the screen; however the passwords are hashed (meaning that what you see there is not the actual root password.) What we will do is to delete the root password. To move the cursor in the file, use h (left), j (down), k (up), l (right), x (delete), and wq! (write changes and quit). Find the line that looks something like this:
Navigate your cursor to the character after the first colon (:), which is 1 in our case. Hit x until you delete all the characters until the next colon, so it looks something like:
Type wq! and you will see a prompt that warns you that you are editing a read-only file. That is normal, so keep going. When you reach the command prompt again, type passwd to change the root password. Then issue the shutdown -r now command or hit Ctrl - Alt - Del to reboot your system. Done!