1

Hello I'm a Raspberry Pi newbie and It seems that I lost my password.

I was trying to ssh but unable to because of password problems. Connecting pi to my TV, I can get to the command prompt #, but I am still unable to change the password. I tried creating a new user but got error 10

I don't want to do too much because I seem to have root access at the pi itself.

Again the Debian install with noobs

4
  1. Put your (micro)SD card into a computer
  2. Copy cmdline.txt to cmdline.txt.bak (just to make a backup)
  3. Open cmdline.txt and add this to the end of the line: init=/bin/sh
  4. Put SD card back into Raspberry Pi and turn it on
  5. You should have root shell and you will be able to change password for any user, eg. passwd pi or passwd root
  6. Remove init=/bin/sh from the end of the cmdline.txt or just delete that file and rename cmdline.txt.bak to cmdline.txt
  7. Reboot RPi

Another method, taken from: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=121407

On the Noobs screen with a keyboard attached, press ctrl-alt-f2 and logon with username=root password=raspberry
mkdir -p /media/boot
mount /dev/mmcblk0p5 /media/boot
cd /media/boot
Then use vi to edit the file directly. (i to enter insert mode, Esc : w q to save & exit when done)

  • The only partition I can see on the SD card is Recover – Mike Alberga Oct 27 '15 at 6:58
  • you can try this: raspberrypi.org/forums/viewtopic.php?f=28&t=121407 – rav_kr Oct 27 '15 at 7:26
  • @MikeAlberga You need to plug your SD card in a linux running box, windows or mac os doesn't read ext partitions by default unless you have any utilities installed. – dhruvvyas90 Oct 27 '15 at 13:16
1

No need to edit cmdline.txt file. Mine is Raspberry Pi 3 with Noobs Raspbian OS.

Steps:

  1. Connect Rpi3 to HDMI interface
  2. You will get UI ( no password prompt)
  3. open terminal
  4. sudo su (will not prompt password)
  5. passwd pi
  6. enter new password
0

You can directly change the root/user password by editing the /etc/shadow file when you plug the SD card into another computer (running linux), see here.

0

I just went through this today using Raspian Stretch with NOOBS. I tried the solutions listed here but they did not work. Here's what worked for me

  • Put your (micro)SD card into a computer
  • Open the BOOT drive
  • Copy cmdline.txt to cmdline.txt.bak (just to make a backup)
  • Open cmdline.txt using NotePad++ or another unix-aware text editor add this to the end of the line: init=/bin/sh NOTE WELL: ADD TO THE END OF THE EXISTING LINE. DO NOT PUT THIS ON A NEW LINE
  • Save the file
  • Put SD card back into Raspberry Pi and turn it on
  • It will get partway through the boot process and then stop. There is no command line prompt, but you will be now type a command
  • type: the following: mount -o remount,rw / Pay attention to spacing
  • type: passwd pi
  • type: sync
  • type: exec /sbin/init (this resulted in an error for me but the password change remained in effect_ Remove init=/bin/sh from the end of the cmdline.txt or just delete that file and rename cmdline.txt.bak to cmdline.txt Reboot RPi

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.