How to Reset Forgotten Root Password in Debian

Once you add a general user into the sudo group, then there is no need to use a root account for the administrative tasks. But due to some odd reason, you are not able to access your primary account?

In that case, the root account can be a savior. But unfortunately, you are not getting the root password too. Now the only way is to reset the root password.

Today, you will learn to reset the root password in Debian 10/11 with a few simple steps.

Reset forgetten root Password

In a simple three steps, you can reset the root password, and the steps are as follows.

Reboot to Grub Bootloader

The foremost step is to restart your system into a grub menu. Once the boot menu appears, select the respective boot partitions in case of multiboot and press e to edit the kernel command line parameter.

Reboot to grub menu and press "e"
Reboot to grub menu and press “e”

Add parameter

In the next screen, you need to find a line containing “ro quiet” and replace ro with rw, and after quiet, add a shell script location init=/bin/sh.

update kernel parameter
Update kernel parameter

Once it is done, press Ctrl-X or F10 to boot into chroot environment.

Update password

If everything is executed as per our instructions, you will see a shell with the pound symbol #. over here, type passwd command to change the root user password.

Enter a new password for confirmation, type once again. If the password gets matched, you will see a message on stdout “passwd: password updated successfully”.

type passwd command to update password
Type passwd command to update the password

The reboot and shutdown command will not work here, so press Ctrl+Alt+Del to reboot your system to regain your root privileges.

Troubleshoot

If the above method didn’t work out for you, and it prints some kind of error like “passwd: Authentication token manipulation error”.

To resolve this error, type the below command:

# mount -o remount,rw /
Remount root partitions
Remount root partitions

After that, type the passwd command to replace the root password and perform the reboot.

Wrap up

The above method should regain your password for the root account. And I believe this method will work on Debian 10/11 and Bedrock Linux.

Leave a Reply