Reset forgotten Linux root password
- Select the kernel
- Press the e key to edit the entry
- Select second line (the line starting with the word kernel)
- Press the e key to edit kernel entry so that you can append single user mode
- Append the letter S (or word Single) to the end of the (kernel) line
- Press ENTER key
- Now press the b key to boot the Linux kernel into single user mode
- At prompt type passwd command to reset password:
# mount -t proc proc /proc
# mount -o remount,rw /
Change the root password, enter:
Finally reboot system:
Boot: linux single
When you get the # prompt you will need to type passwd root to reset password:
Another Method is
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.
First you need to get into grub menu options. This menu is displayed right at the beginning of the boot. If you cannot see your grub menu options press “ESC’ key.
You should get something similar to this:
Now we attempt to edit grub’s boot option. Press “e” to edit the first grub menu option and navigate to kernel line:
Press “e” key again to edit and remove:
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:
At this point, we have edited grub boot menu, and we are ready to boot. Press “b” key to boot.
After successfully boot you will be presented with bash command prompt:
On some linux systems, you will need to completely mount / and /proc partitions. To do that, enter following commands:
mount -o remount,rw / mount -o remount,rw /proc
* NOTE: If you are not sure that if your partition is already mounted RW, run the above command anyway as, otherewise on some systems you will not be able reset your root password. If you fail to do so, you get this error displayed on the screen:
passwd: Authentication token lock busy
* NOTE: On some Linux distributions, you will have /proc mounted already if this is not your case, just run following command:
To reset a actual root password is now simple as typing :
Before you reboot it is recommended but not compulsory to run
command. Your job of reseting a linux root password is accomplished.