In this article we talk a little about the default password for the raspberry pi and then we show a method of recovering the password if you have forgotten it, which I have done in the past.
Default username and password
The default user is pi, and the password is raspberry
Change your password
Once you are logged in as the pi user, it is highly recommended to use the passwd command to change the default password from raspberry to improve security of your raspberry pi
Enter passwd on the command line and press Enter. You will be prompted to enter your current password to authenticate, and then you will be asked for a new password. Press Enter on completion and you’ll be asked to confirm it.
Note that no characters will be displayed while entering your password.
Once you’ve correctly confirmed your password, you’ll be shown a success message (passwd: password updated successfully), and the new password will apply immediately.
If your user has sudo permissions, you can change another user’s password with passwd preceded by the user’s username.
For example, sudo passwd pibit will allow you to set the user pibit’s password, and then some additional optional values for the user such as their name. Just press Enter to skip each of these options.
Remove a user’s password
You can remove the password for the user bob with sudo passwd pibit -d.
Create a new user
You can create more users on your Raspbian installation using the adduser command.
Enter sudo adduser pibit and you’ll be prompted for a password for the new user pibit.
Leave this blank if you don’t want a password but we do not recommend this.
When you create a new user, they will have a home folder in /home/. The pi user’s home folder is at /home/pi/.
Delete a user
You can delete a user on your system with the command userdel. Apply the -r flag to remove their home folder too:
sudo userdel -r pibit
To reset your password
Follow these steps to reset your Raspberry Pi Password
- Power down and pull the SD card out from your Pi and put it into your computer.
- Open the file ‘cmdline.txt’ and add ‘init=/bin/sh’ to the end. This will cause the machine to boot to single user mode.
- Put the SD card back in the Pi and boot.
- When the prompt comes up, type ‘su’ to log in as root (no password needed).
- Type “passwd pi” and then follow the prompts to enter a new password.
- Shut the machine down, then pull the card again and put the cmdline.txt file back the way it was by removing the ‘init=/bin/sh’ bit.
The cmdline.txt should look something like this:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh