recovering root password for debian 9

If you happen to forget the root password and you don’t have sudo configured, then don’t give up just yet and think about reinstalling the operating system again. There is a way to reset the root password.

First reboot your computer. You should see the GRUB menu when your computer boots as shown in the screenshot below. Select Debian GNU/Linux and press e.

You should see the following window. Now go to the end of the line as marked in the screenshot below.

Now remove ‘ro quiet’ part from the end of the line and append ‘init=/bin/bash’ to the end of the line as marked in the screenshot below. Once you’re done, press F10.

You should see the following window.

Now run the following command to remount the root (/) partition as readable and writable:

mount -o remount,rw /

 

Now run the following command to remount the /proc filesystem:

mount -o remount,rw /proc

 

Now to reset the root password, run the following command:

passwd

 

Now type in your new root password and press <Enter> to continue.

Now re-type your new root password and press <Enter> to continue.

 

You root password should be changed.

Reboot