Linux Root Password Recovery

Since I am only working on Fedora and Ubuntu right now, here is the solution for these two Linux distributions.

For Ubuntu, it’s nice because it comes with Recovery Mode.

  • Enter grub menu by clicking on “Escape” button.
  • Choose “Recovery Mode” to boot.
  • When command line prompt, changing password by “passwd” command.

Note: Ubuntu doesn’t have root user but you need “sudo” password.

For Fedora, the key idea is to boot to single user mode by using parameter “1″. You can see all the kernel boot parameters by “man bootparam”.

Any remaining arguments that were not picked up by the kernel and were not interpreted as environment variables are then passed onto process one, which is usually the init program. The most common argument that is passed to the init process is the word ‘single’ which instructs init to boot the computer in single user mode, and not launch all the usual daemons. Check the manual page for the version of init installed on your system to see what arguments it accepts.

  • Enter grub menu and choose one kernel (if there are multiple system).
  • Type “e” to edit kernel options. Normally, it will list three kernel boot up options.
  • root (hd0,0)
    kernel /vmlinuz-2.6.**-**.fc8 ro root=/dev/** rhgb quiet
    initrd /initrd-2.6.**-**.fc8.img

  • Choose the second one. Type “e” again to enter “Minimal BASH-like line editinig” mode.
  • Type ” 1″, (there is a space before 1). Then type “enter”.
  • Note: 1 means boot from init in single user mode

  • Type “b”, which is grub command “boot”. Then type “enter”.
  • After boot up, you will see “sh 3.1#” shell prompt.
  • Change password by “passwd”. Reboot.

Well, it kinda not safe for users since anyone can change root user password. So, in terms of security, we need to:

  • Don’t forget your root password
  • Comment out kernel boot option in /etc/grub.conf

Discussion Area - Leave a Comment




Spam Protection by WP-SpamFree Plugin