:::: MENU ::::

Monthly Archives / February 2017

  • Feb 24 / 2017
  • 0

Reset root password on Linux

Who never forgot a root password on a running machine that you can’t reinstall totally?

Most of the linux distributions do have a recovery partition that you can use for that on startup (I won’t detail this here). But if you don’t have this partition, you can still reset it using generic commands thanks to grub capabilities.

Here is the procedure for resetting root password on most of the linux distros using GRUB:

  1. Reboot the machine
  2. When you get the GRUB menu, go to edit page by pressing e when highlighting the correct line you want to modify (generally it’s the first one, no need to change)
  3. Go to the kernel line and enter again for editing
  4. Remove the quiet word at the end of the line and replace with that:
  5. Press enter to validate your changes
  6. Press b to boot (that way, changes will only be temporary)
  7. You’re now getting a root bash prompt for your machine
  8. The root filesystem is mounted as readonly by default, you have to mount it as read/write by typing
    mount -n -o remount,rw /
  9. Use the passwd command to create a new root password (pay attention to keyboard layout that can be different!)
  10. Reboot and log into your server with your freshly created password

You should now be able to connect perfectly to your server with your new password!

Question ? Contact