How to reset a forgotten password on the Raspberry Pi?
In the Raspbian distribution, the default user is pi and the default password is raspberry. When setting up the single-board computer, you should assign your own secure password. Now it can happen that one has forgotten the password and can no longer log on to the Raspberry Pi. It is not necessary to perform a reinstallation because it can be easily reset. With this recipe you can easily reset the password, so you can log in again as usual on the Raspberry Pi.
- Remove the microSD card from the Raspberry Pi and insert it into a card reader on the computer.
- In the partition boot find the file cmdline.txt
- Open the file with an editor and add the suffix (after a space) at the end of the first line
init=/bin/sh
Save the file
- Then plug the microSD card back into the Raspberry Pi and boot it
- Now enter the following command in the console:
mount -o remount,rw /
- Then enter the following command:
passwd pi
Now you will be asked twice for the new password, which you then enter. Here pi is the user name whose password you want to change. You can also change the username if you want to change the password for root or a custom user.
- To save the settings, enter the following in the console:
sync
exec /sbin/init - Now the changes from point 3 have to be reversed. Open the file cmdline.txt with the following command:
sudo nano /boot/cmdline.txt
Remove init=/bin/sh at the end of the first line (with the previous space). Save the file with Ctrl-x, then y and Enter again. Of course, you can also make this change to another PC with a card reader.
- The password has now been reset and the Raspberry Pi can be used as usual. Start the Raspberry Pi now
sudo reboot
Done!
Congratulations @electrodrome! You received a personal award!
Click here to view your Board
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @electrodrome! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit