Change Raspberry Pi lost password

Too much on a hurry when I choose my Raspberry Pi password, and I wrongly noted it. There is a way to reset the pi user password.

  1. Insert the card in your Mac SD card reader (must work on Window too);
  2. Edit the file “cmdline.txt” and append “init=/bin/sh” (thanks Joe Schmoe). The Rpi will boot in single user mode;
  3. Insert the card in the RPi again and boot up;
  4. When prompt available, enter “su” to log as root (with no password);
  5. Type “passwd pi” and enter a new password;
  6. Remember the new password;
  7. Remove the appended string in the “cmdfile.txt” file. Voila!

If you need a password for the root and you don’t have it either, edit the “/etc/shadow” file and replace the root password with a asterisk. Then it will be no password for the root user. (not tested yet).

9 thoughts on “Change Raspberry Pi lost password

  1. If one has edit the long line after entering the edit mode so one has 3 line to read this string, after adding “init=/bin/sh” one must put the sentance back to the long line by using the backspace key.

  2. Thank you!!!

    Done on ArchLinux ARM and worked like a charm, but the user was ‘root’ in my case.

  3. “init=/bin/sh” did not work for me. I edited the /boot/cmdline.txt “single” keyword at the end and that took me to single user mode. Hope it helps too..


  4. On my Pidora18, in cmdline.txt I also had to change “ro” to “rw” or else the passwd command would fail to write the new password.

    Once that was done, I felt like less of an id10t for forgetting the pw.

  5. In my case it would not accept the default password
    nor what I thought I had changed it to,
    after enabling SSH and being prompted to change the default.

    This time, I simply opened a terminal and typed

    sudo passwd pi

    it asked for a new UNIX password, I typed in my chosen password, and it accepted it. when asked for authentication (installing software or gPartEd) it now accepts my new password.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.