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,385
  • 3
  • 25
  • 51
  • 2
    I recently had to do some surgery on a microSD card file system. I run Windows 10 as my primary OS. I downloaded the free VirtualBox VM software and installed a copy of Ubuntu on it. This then gave me a Linux machine running on Windows. I inserted my microSD card into my Windows PC reader and mounted the Linux file system on the Ubuntu VM and had full access to it. It worked great. I also ended up with a desktop Linux to play with and learn. – Kolban Jul 07 '16 at 16:00
  • @Kolban: that could be a feasible approach. I'll try and let you know whether it worked – Thomas Weller Jul 08 '16 at 08:42
  • If Windows is a secondary operating system, what is the primary one? You should be able to mount the SD directly on Linux or Mac machines. The other thing you could do is to startup directly to the desktop, or get a USB-Serial cable and then login via that. – NomadMaker Jul 25 '18 at 00:19
  • @NomadMaker: I clarified this. I meant "Other than Raspbian on the Raspberry". It's not secondary, it's the primary and only one on my PC. – Thomas Weller Jul 25 '18 at 06:57
  • Why do you have console=xxx three times in your cmdline.txt? Also, you certainly don't need job control to change a password, you real problem is that the keyboard is not responding (likely due to the console misconfiguration). – Dmitry Grigoryev Jul 25 '22 at 10:31
  • @DmitryGrigoryev: I don't know why it's there 3 times. It probably was like that before I started editing. I can't recall ahving changed something with respect to console=. – Thomas Weller Jul 25 '22 at 10:48
  • I see the question is quite old, did you find a solution? If so, could you perhaps write a short answer or one of the existing posts? Otherwise answers will keep coming, mostly poor ones :) – Dmitry Grigoryev Jul 25 '22 at 10: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
  • 131
  • 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
  • I puzzled. Why do you need to remount the drive? I thought that if it booted, and anything was running, that the SD card was already mounted and running. I'm extremely curious as I may have to do this someday. – NomadMaker Jul 25 '18 at 10:31
  • I don't know why we have to remount the drive. Maybe with the new super user permissions, it mounts differently. Regardless, these are instructions that I found by reading other posts, and that's one of the steps that they recommend. – jrgibson Sep 23 '18 at 17:50
-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