How to reset root password on Ubuntu and Debian

If you do not use the ssh keys as a means of connecting to the server, there is a good chance that you will change the default password that you received during activation and cannot remember it after a while. But don’t worry that everything is lost, the root password can be easily reset.

How to reset root password

To reset the password, we must enter the server control panel and click on the VNC button.
We reboot the server using the CTRL + Alt + Del button, and immediately press the “Shift” button and hold it to open the GRUB bootloader.

To start changing the boot file, click on the letter “e“.
Before us we will see such a picture. We are looking for and deleting “ro quiet“.

Then instead of “ro quiet” we insert only “rw” – which means that it will be possible to write and read from the disk, and at the end of this line we add “init=/bin/bash” so that it all looks like this:

Then we press “CTRL + X” and the OS boots up, with the superuser “root“.

If we did everything right, we will be able to reset the “root” password using the “passwd” command.
We execute the command, specify the password twice and get a message that the password was successfully reset.

After we have reset the password, we press the “CTRL + Alt + Del” button again, the server restarts and we enter the server with a new password.