0

the file cmdline.txt got init=/bin/sh added to the end. When I reboot, I do not need a password. but It will not allow me to create one either. do I need to now remove the added instruction? in order to create a new password? It goes through the new password create, but fails, and will not save it.

  • What are you hoping to do by adding this command? Are you trying to reset the Pi or another users password? Or is there something else you want to do? – Nick McCloud Jan 28 '19 at 18:16
  • Your headline is "I added a line to the cmd.txt file ...". Did you mean cmdline.txt? If so then you cannot add a line to it. It must have only one line otherwise it will break your bootup. – Ingo Jan 29 '19 at 1:27
2

From the title of your question I'm guessing you are following some instructions form somewhere telling you to add init=/bin/sh to cmdline.txt in order to boot your Pi in "single user mode". What you are doing here is interrupting the normal boot process after the bare minimum required and running a shell as the root user -- the result being you are logged in without a password.

The instructions then probably tell you to use the passwd pi command to re-set the forgotten password for the user pi? However, because the Pi hasn't completed the usual boot process the filesystem hasn't been mounted fully yet and is still "read-only". The result being that the passwd pi command can't save the new password to the filesystem so has no effect when your reboot.

The solution is to (re-)mount the SD card "read-write" first, before you run your passwd pi command. Do this with the mount -n -o remount,rw / command followed by the passwd pi command. Finally, remove the init=/bin/sh from cmdline.txt and reboot.

| improve this answer | |
  • Before reboot, you could also fix up cmdline.txt – Jaromanda X Jan 28 '19 at 21:32
  • Good point, I'll amend my answer. – Roger Jones Jan 28 '19 at 21:58

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.