To reset lost root password in recovery mode (DEBIAN/UBUNTU)

Single User Mode in Ubuntu:
To reset the root password you have to boot to single user mode. Follow to steps below to boot to the single user mode in Ubuntu.


Please note that Ubuntu use the GRUB 2 as bootloader. The first boot option will be used by GRUB 2 by default and it will be used for booting without waiting for user input. So you need to interrupt the boot process for getting boot menu.


To edit the boot menu in Ubuntu:
For that press down the “shift” key while booting and you will get the GRUB boot menu.


Normally the top GRUB entry will be pointing to your normal boot entries. It will look similar to:


           Ubuntu, with Linux ( kernel version + options)


Press the ‘e’ key to edit the kernel parameters.


Now what you see are the boot entries. Now find the kernel line and append “init=/bin/bash” to it.


The kernel line will look like:
           linux root=UUID=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx ro vga=794 quiet splash


Go to the end of the line using your arrow keys and append init=/bin/bash to it as follows:


           linux root=UUID=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx ro vga=794 quiet splash init=/bin/bash


Now boot with the edited kernel parameter by pressing ctrl+x.


Your machine will now do a one time boot into single user mode. Once you reboot the changes you just made to Grub will be reverted.

Remount root partition as read/write in single user mode and reset password:
Now your /root partition will be mounted as read only. Type in the following command to mount the /root partition as read write.


            mount -n -o remount,rw /


Now changing the root password is a piece of cake!!! just type in:


            passwd root


And specify the new password.


Leave a Comment