If you forget your Raspberry Pi’s password, it’s a fairly useless little machine. To fix this problem, Raspberry Pi Spy shows how to reset the password with a simple edit to a TXT file.
All you need to do is grab your Raspberry Pi’s SD and put it into your computer. There should be a file called cmdline.txt. Open that with a text editor and add this line to the end of the existing text:
Save the TXT file and take your SD card back to your Pi. Boot up and you should see a flashing cursor. Enter this command into the Pi:
Enter in your new password two times. Then type this command:
sync exec /sbin/init
Your Pi will boot up like normal. When it’s done, shut it back down, and take your SD card back to your computer. Delete the line in the TXT file you added above. You should now be able access your Pi again. Head over to Raspberry Pi Spy for a more detailed walkthrough.
How to Reset a Forgotten Raspberry Pi Password [Raspberry Pi Spy]