-1

During installation, I've set up a password which I have typed wrong twice, and now I'm not allowed to gain access to my root account in Debian.

I'm trying to procedure like http://xmodulo.com/how-to-reset-root-password-in-debian-ubuntu.html (I'm using Debian 7 Wheezy). In spite of doing everything like that, passwd command is not recognized by bash in that environment. Any idea on how to solve this issue?

Thanks!

darth_alexious
  • 103
  • 2
  • 7
  • 1
    Are you sure you're mounting the root partition? – gparent Nov 18 '14 at 18:56
  • If I dind't achieved to mount root partition, passwd command would not be available? – darth_alexious Nov 18 '14 at 18:57
  • 2
    Well that article makes some stupid assumptions (`/boot` is not necessarily on the same partition as `/`) and since you didn't give us the commands you ran or their output I'm trying to find out if possibly you could have unmounted `/`. – gparent Nov 18 '14 at 19:07
  • 1
    While learning the "right" way to fix this is a good exercise, if all you did was install Debian you could just consider reinstalling. – Gene Gotimer Nov 18 '14 at 19:26

2 Answers2

1

You can do this a few different ways:

1) Boot into single user mode(assuming your grub install isn't set to boot in 0 seconds). To do this you'll need to stop grub and edit the boot options(E for Grub legacy or Ctrl+X for Grub2), find the line for the kernel and add 1 or single to the end or it. Then boot.

2) use your installation media(or a live Debian CD/DVD).
1. Boot it up, and get to a terminal(Ctrl+Alt+one of the F keys 1 - 5)
2. Make a directory to mount your root file system to and mount it there
3. mount --bind /dev [your root FS location]/dev
4. mount --bind /proc [your root FS location]/proc
5. mount --bind /sys [your root FS location]/sys
6. chroot [your root FS location]
7. Run your passwd command and anything else you need to do before rebooting
8. make sure you exit from the chroot before trying to issue the reboot command

3) Use another Linux system to generate the encrypted password, mount the root file system from any live CD or installation CD and use vi(or whatever text editor) to modify your shadow file

MVanOrder
  • 175
  • 5
1

I expect you didn't actually get the root partition mounted, or it didn't pivot_root so the initrd / is replaced by your actual root filesystem, or your path isn't properly configured. Check if there is a passwd binary in /usr/bin/passwd. If there is, call the /usr/bin/passwd binary directly or update your path like export PATH=/usr/bin:$PATH and then call the passwd command normally.

If there isn't, you need to pivot_root to your actual root fs. pivot_root example copied from the link:

mount /dev/hda1 /new-root
cd /new-root
pivot_root . old-root
exec chroot . sh <dev/console >dev/console 2>&1
umount /old-root
Andrew Domaszek
  • 5,103
  • 1
  • 14
  • 26