Original link: http://www.raspberrypi-spy.co.uk/2014/08/how-to-reset-a-forgotten-raspberry-pi-password/
The general process is this:
1. First remove the SD card from the Raspberry Pi,
2, on another computer, modify the initialization process to the bin directory of SH;
3, and then insert the Raspberry Pi start up, will stay on the command line, here by passwd plus your username to set the password (even if root can also be modified here, before the initialization of the root password is not sure)
4, Raspberry Pi shutdown, remove the SD card, insert another computer, restore the boot file, modify the password process completed
Detailed steps to see translation
Translate as follows:
Step 1–grab the SD Card
Step 1-Remove the SD card
Power down the Pi and remove the SD card. Insert it into your PC.
Turn the Raspberry Pi off, remove the SD card, and plug it into your computer
Step 2–edit Cmdline.txt
Step 2-Edit cmdline.txt
The boot partition should be visible and contain a file named "Cmdline.txt". Edit this file in a text editor and add the following to the end of the existing text:
The boot section is visible and contains a file named "Cmdline.txt". Edit the text in the editor and insert the following into the last of the existing text
Init=/bin/sh
If The original content was:
If this is the original:
Dwc_otg.lpm_enable=0 console=ttyama0,115200 kgdboc=ttyama0,115200 console=tty1 root=/dev/mmcblk0p2 ROOTFSTYPE=EXT4 Elevator=deadline rootwait
It should now:
So the editor should be like this:
Dwc_otg.lpm_enable=0 console=ttyama0,115200 kgdboc=ttyama0,115200 console=tty1 root=/dev/mmcblk0p2 ROOTFSTYPE=EXT4 Elevator=deadline rootwait init=/bin/sh
Make sure it's all one line! Save the text file and eject the SD card from the PC.
Make sure all content is on the same line. Save text content, remove SD card from pi
Step 3–reset the Password
Step 3-Reset your password
Insert the card into a Pi, that's connected to a monitor and keyboard. Power up the Pi. There may is a delay but you should is presented with a flashing cursor.
Insert the SD card into the Raspberry Pi (we need to connect the monitor and keyboard here). Turn on the Raspberry Pi and expect to wait a while before displaying the flashing cursor.
At the prompt type the following command:
After the identifier, enter the following command:
passwd Pi
You'll then is prompted for a new password. Enter it carefully and press the [Return] key. It'll now ask retype the password.
You will be prompted to enter a new password, please enter it carefully and hit enter. You will be prompted to confirm your password again
The password has been changed.
So the code is modified.
Now type the following commands:
Now enter the following command to synchronize and execute the initialization program
Syncexec/sbin/init
The Pi would continue to boot and return to the normal command line prompt.
The Raspberry Pi will continue to boot.
Shutdown the Pi and power it off.
Turn off the Raspberry Pi and power down.
sudo halt
Step 4–edit Cmdline.txt
Fourth Step-Edit Cmdline.txt text
Using the PC edit the "cmdline.txt" file again and remove the "init=/bin/sh" text you added in Step 2.
Edit this text again with your computer: Delete the last data we added in the second step
You can now return the SD card to your Pi, reboot and use the new password.
Now you can insert the SD card into your Raspberry Pi, and start again to use the new password.
What about forgetting the Raspberry Pi password?