0

I'm trying to reset my Raspbian password, so I took the SD card to Windows and added the text init=/bin/sh (including a space) at the end of the line of the file cmdline.txt. I did that with Notpad++ to preserve Unix style line endings.

The full line is now

dwc_otg.lpm_enable=0 console=ttyAMA0 console=ttyUSB1 console=tty1 root=/dev/mmcblk0p2 rootwait init=/bin/sh

When booting, there's a line that says

/bin/sh: 0: can't access tty; job control turned off

Googling for this, I find that it often happens with IOs connected, which I don't. Anyway, I also tried adding avoid_safe_mode=1 in config.txt.

Still the same issue. I'm running out of ideas and out of time. I have to keep the data on the SD card, so I can't simply reformat.

I have a Dell USB keyboard connected. I can see text via HDMI, but I can't type anything. NumLock on the keyboard does not react, so as far as I can say, the keyboard does not work. The keyboard itself is ok. I can use it on my laptop.

Raspbian says (among others):

usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[...]
usb 1-1.2: Product: Dell USB Keyboard
usb 1-1.2: Manufacturer: Dell

I tried the suggestions here: I can't log in via SSH and I only have Windows as a external OS, so I can't mount the SD card to erase the password in /etc/passwd.

How do I reset the password?

Thomas Weller
  • 2,517
  • 3
  • 30
  • 54

3 Answers3

2

I recommend you delete console=ttyAMA0 from cmdline.txt.

You've got HDMI video and USB input, ttyAMA0 implies you're using a serial console. HDMI video/USB input will be tty1.

If you are using a serial console, you can add that option back after you've sorted out your password.

Everything else looks ok.

NameGoesHere
  • 121
  • 3
1

I encountered this problem when trying to reset a password that I had forgotten on my Raspberry Pi Zero W. This is what I now have in my cmdline.txt file to remind me how to reset the password in the future (there should only be line breaks before # pound signs; if you see other breaks, it's because of auto-line wrap):

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
# If you forget the password, add the following to the end of the single line in the cmdline.txt file on your Pi
#   systemd.unit=rescue.target init=/bin/sh
# Then:
# 1. Boot the Raspberry Pi (you'll need a USB keyboard)
# 2. Wait a bit. It will complain about "/bin/sh: 0 can't access tty: job control turned off
# 3. Hit enter a couple of times to get a # prompt.
# 4. Type "su" (without the quotes) at the prompt and hit enter
#     You will receive the following two lines:
#       bash: cannot set terminal process group (-1): Inappropriate ioctl for device
#       bash: no job control in this shell
#     The prompt will now look like "root@(none):/#"
# 5. Remount the drive by typing "mount -o remount,rw /" and hitting enter
# 6. Type "passwd pi" and hit enter
# 7. Enter your new password and hit enter
# 8. Enter your new password again and hit enter
#     You should see "passwd: password updated successfully
# 9. Unplug your Raspberry Pi
#10. Open this file (cmdline.txt) on another machine and delete the " systemd.unit=rescue.target init=/bin/sh" from the end of the first line.
#11. Save this file and reboot your Raspberry Pi.
jrgibson
  • 11
  • 1
-1

Adding init=/bin/sh to cmdline.txt sometimes causes this error /bin/sh: 0: can't access tty; job control turned off

If the keyboard doesn't work either you can mount an SD card on another Linux and add ssh key for pi user or edit /etc/shadow

  1. Put the SD card via card reader
  2. sudo fdisk -l if your disk /dev/sdb there must be two partition; /dev/sdb1 and /dev/sdb2 (in this case /dev/sdb2 must be mounted)
  3. sudo mkdir /media/pi
  4. sudo mount /dev/sdb2 /media/pi it mounted
  5. cd /media/pi

if your raspberry pi can get IP and ssh working you can add your ssh public key to

nano /media/pi/home/pi/.ssh/authorized_keys

unmount SD card

umount /dev/sdb2

insert SD card to raspberry pi, plug LAN cable, and boot now you can connect with the IP

ssh pi@LOCAL_IP_ADRESS

if ssh connection is not possible you may want to update /etc/shadow :

I have just returned to my Raspberry Pi after a year and can't remember my login