Things happen. You loose password, forget passwords etc.. You can recover your root password if you have access to the server directly. Its slightly different for different distributions. So we will look at teh Debiandistributionexample.
The steps for reseting root password on Debian machine through single user
mode is shown below.
1. Reboot the server and enter GRUB screen (The screen which shows the
2. Once the GRUB screen is displayed, use the arrow keys to select the
boot entry showing kernel entry.
3. Press the key “e” to edit the entry
4. At the end of the kernel line add the word “1” or “single” (without the
5. After adding the entry press ESC key to go back to the grub screen
6. press the key “b” to boot this kernel in single user mode
7. You will be now logged in to the shell as root user
8. In the shell type: passwd root
9. It will prompt you for your new password and will ask you to confirm it.
10. Now root password has been reset, you can now reboot your server using
the command “reboot”
Now keep it so that you don’t make this ahabit. Good luck with your root password.