How to reset root password on Debian 9 (Stretch)

1
Reset root password on Debian 9
Reset root password on Debian 9

Have you forgotten your root user password on Debian 9?, do not worry, I will show you here, how to reset the root password on Debian 9. You simply follow the below steps and recover (set a new password) the root password.

Start your Debian 9 machine and Press any key to stop the boot process. Press “e” to edit the kernel command line parameters.

Reset root password on Debian 9 - Grub
Reset root password on Debian 9 – Grub

Use “down arrow” key for scrolling down. Go to the line that starts with the word “linux” and use “forward” arrow or press “End” button to go to the end of the line, and then add “init=/bin/bash“.

Reset root password on Debian 9 - Editing Kernel Commands
Reset root password on Debian 9 – Editing Kernel Commands

After you have added the entry, press “Ctrl + x or F10” to boot Debian 9.

Debian will now boot into single user mode, with the root filesystem mounted in “read-only mode“.  So, use below command to mount the root file system in “read-write mode“.

mount -o remount /
Reset root password on Debian 9 - Mount Root File System
Reset root password on Debian 9 – Mount Root File System

Finally, change the root user password using “passwd” command.

passwd
Reset root password on Debian 9 - Reset Root Password
Reset root password on Debian 9 – Reset Root Password

Reboot your system and use the new password we set now for the root user on your system.

That’s All.

You might also like