A Root Password can be exceptionally difficult to recover, if you loose or forget it. I think I would go as far as to say, the Root Password is nearly impossible to recover. However, if you are using Debian GNU/Linux, it may be possible to re-set the Root Password, to a new password, to be used going forward.

The process here is possible only if:

  1. You are using the GRUB boot loader &
  2. Your root partition is not encrypted!

This process wont be as difficult as it may seem. If you will simply follow the steps I give you very carefully, I’m sure you will be pleasantly surprised. It is important that you read this entire page of directions completely, before actually performing any of the steps. This way if you have any questions or concerns, you can address them before starting the process.

Root Password Changing Process

  1. To get started, your will either need to reboot your system, or turn it on from the “Powered Off” state.
  2. When Grub loads, select the kernel that you want to edit using the up/down arrows. (If you’ve only installed one Linux Operating System, the kernel that is selected and is at the top is the default kernel you use. Also, unless you have configured your system not to automatically load the default kernel, you have to be quick in doing this, or it will proceed to boot into the default kernel in just a few seconds.)
  3. You will then press the “e” key on your keyboard to edit the selected kernel.
  4. Using your up/down arrows, scroll to the line with the kernel on it and press the “e” key again.
  5. At the end of the line, add… init=/bin/sh …then hit the <enter> key. This tells the system that after loading the kernel, go directly to a bash shell, and then takes you back to the kernal screen.
  6. Then press the “b” key to boot.The system will load and take you to the command/bash prompt (i.e. sh-3.1#).
  7. At this point, your root partition is mounted as a “read only” partition, so you won’t be able to change the password on it until you mount it as a “readable/writeable” partition. So, at the command/bash prompt (i.e. sh-3.1#) type… sh-3.1# mount -orw,remount / …then hit the <enter> key. This tells the system to remount the partition with the new option “rw” (readable/writeable).
  8. Now, you will change the password. At the command/bash prompt (i.e. sh-3.1#) type… sh-3.1# passwd …then hit the <enter> key. You will be prompted to enter a new unix password and then confirm it. Each time you type your new password in you will need to hit the <enter> key.
  9. After selecting & confirming your new password you will get a message: passwd: password updated successfully This confirms that your new password was entered and confirmed and has now been saved. You will notice that you have also been returned to the command/bash prompt (i.e. sh-3.1#).
  10. You will now need to remount the file system as read-only. At the command/bash prompt (i.e. sh-3.1#) type… sh-3.1# mount -oro,remount / …then hit the <enter> key. This tells the system to remount the partition with the default option (read only).
  11. The process will complete and you will be returned to the command/bash prompt (i.e. sh-3.1#), with you partitions intact as they were before we performed the password change. At the command/bash prompt (i.e. sh-3.1#) type… sh-3.1# exec init …then hit the <enter> key. This tells the system to replace the current process with “init” and start the system. (Which is what the kernel would have done by default before we edited it with init=/bin/sh to take us to the command/bash prompt.) Your system will now boot normally.

Root Password: Summary

These steps, for changing the Root Password, have been tested on a Debian GNU/Linux system running the “SARGE” release, and work just fine. However, I have not tested these steps in “ETCH”, “LENNY” or “SQUEEZE” releases.

UPDATE: This post is old and has been modified for use in new WordPress Theme Designs. In some cases, Categories, Tags and/or the actual Content has been modified. Content found in this post may be dated and irrelevant and should be used with caution. This post may be original to this site or may have come from one of many other WordPress-powered websites I’ve run since 2008. All previous websites have been shuttered; though new ones may pop up in the future.