How To reset the root password in (Debian) Linux

Many times I was in the situation where I am creating an account on a website and asking myself “what will I do if I forget the password?” and then check if that website offers the option of password recovery. When this situation is about the computer you’re using, there is no such option, so you must find other ways for recovering the password. One of these situation is root password in Linux.

If single-mode boot doesn’t help (because you are being asked for the root password if you want full access), then the easiest solution is to do the following things…

In GRUB boot menu press “e” key to enter Edit Mode. Using the arrows on the keyboard select the line which contains a reference to kernel then press “e” again, in order to edit that line (if you aren’t already able to edit it). At the end of this line add a space and this text:

init=/bin/bash

Press ENTER to apply changes then “b” to boot. After you are at the # prompt, enter the following commands:

mount -o remount,rw /

which will mount in Read/Write mode the whole disk, allowing you to edit the files. Normally, the disk is Read Only.

After the disk is mounted, enter:

passwd root

then type your password. After this, enter:

reboot

and that’s all, folks! 🙂


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.