Don't remember the password you set while installing Raspberry Pi OS? It happens.
Raspberry Pi OS is set to auto login and doesn't even need password while using sudo. Since you are hardly entering the password anywhere, it is only human that you'll forget it.
Resetting the Raspberry Pi OS password is not complicated. In this tutorial, I'll cover both cases where you can auto login and where you cannot login to your system.
Let's start with the first method.
Method 1: If you can auto login
Here's the deal: By default, Raspberry Pi OS is set to automatically log in to the system without requiring a password.
If that's the case, you are in luck. Raspberry Pi OS is configured to not ask for a password with sudo. Since you can log in automatically, and no password is required for sudo, resetting the password will be super easy.
You just have to type this in the terminal:
sudo passwd username
Here's an example where I changed the password for the main user named ushika
:
Alternatively, you can use the GUI tool provided by
In here, under the System tab, you'll see the option to change the password.
Method 2: If you cannot auto login
This is slightly complicated and longer procedure. If you cannot log in to your Raspberry Pi OS, you can modify a few parameters to boot into the root shell and reset the password from there.
You need a separate computer, preferably running Linux here.
Step 1: Modify cmdline.txt file
Take out the micro SD card from the Pi and put it in your computer. On Linux, it should automatically mount. All you have to do is to edit the /boot/cmdline.txt file.
You can do it graphically or use the terminal; the choice is yours.
There should be one or more lines and you have to add init=/bin/sh
at the end of this last line, NOT on a new line. There must be a space before init=/bin/sh.
Now, this last line should look like this.
console=serial0,115200 console=tty1 root=PARTUUID=585e914d-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=IN init=/bin/sh
Save the file and unmount the SD card.
Step 2: Boot Raspberry Pi into the root shell
Plug the modified SD card into the Pi again and power it on.
Now when you boot into the Pi, it will drop you into the root shell. In here, you can run commands as root and make changes to your system.
But for that, you have to remount the system with read-write access (you must type the command exactly):
mount -o remount, rw /
Now, change the password for the user:
passwd username
If you do not remember the username, you can run ls /home/
and it should show what users are there on your system.
Enter the new password twice and then use this command to make sure that the changes are saved to the disk:
sync
Everything seems to be set now. But you still have to revert the changes you made in cmdline.txt file otherwise you'll keep on booting into the root shell.
Use the command below to reboot into Raspberry Pi OS but temporarily bypassing the root shell:
exec /sbin/init
Once you are in your regular Raspberry Pi system, modify the cmdline.txt file again using this command:
sudo nano /boot/firmware/cmdline.txt
Remove the init=/bin/sh
and press Ctrl+X to save the changes.
Next time you boot, you'll normally boot into your system.
Conclusion
There could be a few other methods for resetting the Raspberry Pi password. I came across them in various forum discussions. However, I find these two the most reliable options.
I hope this tutorial helps you reset the password on your Raspberry Pi OS. Let me know if you have questions.