Recover - Reset forgotten linux root password


From Linuxconfig.org

Jump to: navigation, search

Contents

Introduction

This method of reseting/recovering of lost Linux root password should work on most of the linux distributions. I have tested this method for couple years already, starting with debian woody via redhat and suse to ubuntu hardy. If you run lilo boot loader instead of grub you can use the same method but with some modifications on how to edit lilo boot prompt.

Edit Grub boot menu options

First you need to get into grub menu options. This menu is displayed right at the beginning of the boot. If you can not see your grub menu options press "ESC' key. You should get something similar to this:

grub boot menu

Now we attempt to edit grub's boot option. Press "e" to edit the first grub menu option and navigate to kernel line:

edit grub boot option with "e" key

Press "e" key again to edit and remove:

quiet splash

and add:

init=/bin/bash

You may have some different boot options but the main part you need to change/add is init=/bin/bash. You will get something similar to this:

change to init=/bin/bash

Press enter:

ready to boot from edited grub menu

At this point we have edited grub boot menu and we are ready to boot. Press "b" key to boot.

Remount / and /proc

After successfully boot you will be presented with bash command prompt:

bash command prompt

On some linux systems you will need to completely mount / and /proc partitions. Enter following commands:

mount -o remount,rw /
mount -o remount,rw /proc
  • NOTE: If you think that your partition is already mounted RW run the above command anyway as on some systems you will not be able reset password. If you fail to do so and you get this error:
passwd: Authentication token lock busy
  • NOTE: On some Linux distributions you will have /proc mounted already if you do not have just run:
mount /proc
mount and remount partitions

reset / recover forgotten linux root password

Reseting password now is as simple as typing :

passwd
reset / recover forgotten linux root password

Reboot

Before you reboot is recommended but not compulsory to run

sync

command. You job of reseting a linux root password is done.

Personal tools