1

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?

  • 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 7 '16 at 16:00
  • It is unclear what your are asking, but you have obviously fiddled with cmdline.txt in other ways. I suggest you put it back and change password in the normal way. – Milliways Jul 8 '16 at 0:34
  • @Kolban: that could be a feasible approach. I'll try and let you know whether it worked – Thomas Weller Jul 8 '16 at 8:42
  • 1
    Why do people say "this is unclear" ? It is perfectly clear to me, and in fact, I am getting the same problem. I want to reset the password as I no longer have it. I have added "init=/bin/sh" to the end of the single line in cmdline.txt and I get exactly the same message. What is unclear? – jamspandex Jun 24 '17 at 14:38
  • Because the OP did not ask an actual question! One of the things that distinguishes this site from others is insisting on quality questions. – NomadMaker Jul 25 '18 at 0:13
1

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.

0

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.
  • 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

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.