Jul 132010
 

Sponsored Link
If you forgot your root password for your debian server use the following procedure to reset.

Boot to the GRUB menu. Then, press <e> (for edit) before Linux has a chance to boot.

Using your keyboard arrow keys, move the cursor down a line or so, and press <e> (for edit) again, you should now be on the kernel line, and press <End> to go out to the very end of that line. Now hit the spacebar once, if necessary, to add a space, and then add one of the folllowing:

init=/bin/bash

or

init=/bin/sh

Then press <Enter>, and you're back at the kernel line, press <b> (for boot) and the computer will proceed to boot to a root prompt.

At this point, the root file system is still mounted read-only, so enter the following command:

mount -n -o remount,rw /

Then type:

passwd

Enter your new password. Retype if asked to confirm.
Then restart the machine by typing:

reboot

Now you should be able to login with your new root password as required.

Sponsored Link

 Posted by at 4:40 pm
  • Douglas

    I use this command, but it’s not recovery my password

  • Pisithanate

    When i press “b” is just boot up, i can’t type “mount -n -o remount,rw /”

  • johnathan

    I followed the instructions and they worked up until I tried to change the pw. I got

    “passwd: User not known to the authentication module”
    “passwd: pasword unchanged

  • lom56

    thanks, this article useful to me

  • Oluype

    Clear and simple instruction. thank worked just fine for me…

    Regards

  • cleopatra

    Indeed, it worked just fine on my cruncgbang. Thanx!

  • Bernard

    My way of solving this issue:
    1. Start up the computer with a linux live CD (or USB key). Doesn’t matter if it’s a Debian, Ubuntu or probably any other distro – I used an Ubuntu 11.10 USB key.
    2. Using the Disk Utilities available from your device, mount the partition that hosts your /etc folder (probably marked as bootable)
    3.in a command line, go to ./etc under your mounted partition, probably in /media/[a long hd id-like number]. Notice the dot (.) before /etc; don’t go to “/etc”. You can check that you’re in the right folder with a little “grep -i [name of a user of yours (not root!)] shadow” If you get anything, you’re in the right folder and you can proceed to step 4.
    4. Just to be safe, make a backup copy of your “shadow” file. I simply used a “cp ./shadow /media/[an inserted and mounted USB key]/shadow” command.
    5. Using your favorite text editor (I used nano because I know it’s available on my key), edit your “shadow” file (“nano shadow”)
    6. Locate the root line. It’ll look something like “root:[encrypted pw]:12345:5:99999:::” (figures are made up)
    7. replace the [encrypted pw] part of the line with a single “!”. Yep, just an Exclamation mark with no double quotation mark. That tells Linux to authorize the mentioned user to access the system with no pw, so be cautious ! Your line will then look something like “root:!:12345:5:99999:::”
    8. Save your changes and exit the command line
    9. Back to your Disk Utilities program, unmount the partition you mounted in step 2 above.
    10 Turn your computer off and remove all media, may it be USB key, CD, or whatever.
    11 Restart your computer and, in the grub menu, choose “rescue mode”. You’ll find yourself in a command line of a root session with no pw.
    12 change your pw with a “passwd” command. If you’re not sure, “man passwd” should help.

    I know it’s somewhat lenghty, but it worked for me in a few minutes.

  • RobChitown

    Original post worked like a charm – init=/bin/bash didn’t work – locked the machine and did a hard reboot. Then tried init=/bin/sh and was in in seconds. Entire process took 2 minutes after reading this post. For the linux newbies the kernel line starts with “linux …” just goto the end and add the proper init=…”

    Thanks again,

    Rob

  • ik

    doesn’t work at all , like the simular shit on the net. after “mount -n -o remount,rw /” there is just an error and a bunch of info on !!!correct-comando’s!!!

    seems this isn’t a full comando?????

    nicely done.
    useless like al the others i tried.

  • Sean P.

    Bernard, you’re the man! easy, understandable instructions. Worked perfectly for me while the actual post above didn’t work.
    Thanks Bernard! Cheers!

  • Uncle Grasshopper

    Man… your comment has saved my life!!! Thanks a lot!!!

  • FreeBSD

    useful, should probably print this….

  • Luis

    Thanks a lot for your help. Instead of “mount -n -o remount,rw /” I used “mount -a”, also, instead of , worked for me….

  • Herick

    Thanks, worked for me.

  • Mouseanony

    Doesn’t work on 7, you can’t add it at the end of the kernel and just hope it works. It won’t; there’s no kernel line.

    It needs to be added after “ro quiet” on the linux line.

  • boyka

    THANK you very much it’s very interessting