2

By mistake I locked my admin account on Debian with passwd -l. I'm trying with live CD to unlock my account with no sucess. I've tried editing passwd file by removing x, but that didn't work.

/etc/passwd
root:x:0:0:root:/root:/bin/bash

any ideas?

  • 1
    The password is store in the shadow files – X Tian Mar 8 '14 at 20:16
  • I know, i mounted ssd drive but all i see is .efi file! – Test Mar 8 '14 at 20:18
  • Edited from recovery mode. Solved – Test Mar 8 '14 at 21:04
4

If you have an account with sudo permission, you can run:

sudo passwd root

to unlock root password.

If you don't have sudo permission, you should boot into single user mode (by editing boot option if you use grub) or using a live cd, then editing /etc/shadow file (not /etc/passwd) to remove pair of exclamation mark !! or ! before hash password, example:

root:!!<hash password here>:9797:0:::::

After that, reboot and now you can log in with root again.

  • I know, i mounted ssd drive but all i see is .efi file! – Test Mar 8 '14 at 20:20
1

The password is not store in /etc/passwd the x is a dummy entry /etc/shadow contains the password.

Read man shadow for more information.

1

You shouldn't even need to boot with a LiveCD, simply boot your system with either the string 1 or the word single at the end of your linux ... stanza when GRUB2 initially is displayed.

Example

When booting the system if you access the boot menu options for the kernel from the GRUB2 menu, you can append the appropriate string at the end to gain single user mode access to your system.

linux /vmlinuz-3.13.5-101.fc19.x86_64 root=/dev/mapper/fedora_greeneggs-root ro rd.md=0 rd.dm=0 vconsole.keymap=us rd.lvm.lv=fedora_greeneggs/swap rd.lvm.lv=fedora_greeneggs/root rd.luks=0 vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 single

NOTE: You typically hit the e key and then arrow down to the linux ... line adding the string "single" to the end. Then hit the F10 to boot it.

Once booted you should be able to access your /etc/shadow file and remove the existing password from root's entry, making it blank. If you then reboot the system you should be able to get in with a blank password and use passwd to reset it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.