Reset Raspberry Pi Password

It is easy to forget the password to a Raspberry Pi that isn't used much. Luckily it is pretty easy to reset the default password.

a year ago

Latest Post Cloud Development Kit for Kubernetes (cdk8s) by Tyler Moon

Raspberry Pi computers are awesome for small projects and tiny home webservers. Check out this article here on how to set up a network-wide DNS ad-blocker using a Raspberry Pi and a project called PiHole.

After setting up a Pi for a home server use, it can be left alone doing its thing for a long time without you having to log in to it. This can lead to a scenario where one forgets the pi user password! Don't fear though there is a simple procedure to reset the password of the default pi user assuming you have access to the Pi itself.


Extract the SD Card

The first step here is removing the SD card from the Pi so that we can modify a config file from another computer. Turn off your Pi by unplugging it and then remove the micro SD card. Insert the card into your micro SD card reader and then plug it into another computer.

Edit a file

After plugging in the SD card to your computer open up the cmdline.txt file and add the following to the end of the only line in the file.

Note: Make sure that you put the text at the end of the line and not on the next line. It is very important that there is only one line in this file or it will break some startup procedures!

Change the Password

Eject the SD card from your computer and put it back into the Pi. Then plug in the Pi, and connect a monitor and keyboard to it. After it boots up the screen will appear to be frozen but you can actually type commands and they should show up.

Mount the root of the filesystem by running the following command

mount -o remount, rw /

And then run the Linux password change utility with the following

passwd pi

Follow the prompts to set the password.

After completing the passwd command run the following two commands to finish the reset.

exec /sbin/init

The last command should reboot the Pi and show the normal login. At this point, you should be able to login with the pi username and the password that you just set.

Revert the changed file

Shutdown your Pi by either unplugging the power cable or executing sudo shutdown -h now and then remove the SD card once again. Put the SD card back into your SD card reader and back into the other computer. Open up the cmdline.txt file and remove the init=/bin/sh that you added earlier. Save the file and then put the SD card back into your Pi. Now your password should be reset and the Pi should boot as normal.


In this article, we saw an easy procedure to reset the default pi users password on a Raspberry Pi.

Tyler Moon

Published a year ago