How to Reset Lost Password - Raspberry Pi
If you have lost you “pi” or “root” user password, the only way to rebuild the password is to reboot the Raspberry Pi in a special mode so that you can reset the password. To do this is to insert the card into a Mac or Windows machine and change the “cmdline.txt” file. Add init=/bin/sh to the end of the line.
**Example:**Before it might look like:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwaitAfter adding the command it will look like:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/shPut the card back in the Raspberry Pi and start it. The system should start booting and then it will drop you at a command prompt. At this command prompt type:
# mount -o remount,rw /
# passwd pi(enter a new password)
# sync
# exec /sbin/initThe boot process will then continue and then again drop you at a command prompt. Once it done you have to Re-edit the cmdline.txt file in /boot and now remove the init=/bin/sh from cmdline.txt.