How to Reset Forgotten Raspberry Pi Password: Recover Login Details

How To Reset Forgotten Raspberry Pi Password

How to Reset Forgotten Raspberry Pi Password: Recover Login Details

I have been part of the Raspberry Pi community for a quite significant time now, and through this period I have seen some repeated questions again and again. One of the most asked common questions is how to reset Raspberry Pi password. Today, I am going to provide you quick guide on recovering the login details (especially if you are using only the root credentials) of your Raspberry Pi setup.

Let’s go the method below:

Recover Raspberry Pi Password

To reset Raspberry Pi password, you will need first to shut down the Raspberry Pi device. Physical access to the SD memory card is required to complete the process for resetting the credentials when you forgot Raspberry Pi login details.

Things needed

  1. Raspberry Pi
  2. Compatible SD card for Pi
  3. Laptop/Desktop PC
  4. Raspberry Pi display
  5. Power adapter for Pi
  6. Keyboard and mouse
  7. SD card reader for PC (optional)

After you gather the required components, let’s move to the steps.

Step-1: Get the SD Card

After you power off the Pi, remove the SD card from it. Now, attach the card to your laptop or desktop PC.

Step-2: Edit the Text File

Every Raspberry Pi boot partition contains a text file named as a ‘cmdline.txt’ which you need to edit to step into the process of Raspberry Pi forgot password reset.

You will see a line of code looking like below:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

cmdline.txt code

Edit that line and write at the end of the line, ‘init=/bin/sh’ and now your command line should look like below:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh

cmdline.txt init

Doing this makes sure that your machine will now boot with a mode of single user.

Save the text file.

Step-3: Power on the Pi

Remove the SD card from your PC. Attach it to your Raspberry Pi device and power on the setup.

Step-4: Reset raspberry pi password

When you see a prompt window, enter the command below:

mount –rw –o remount /

mount –rw –o remount

Press Enter. This will open the Raspberry Pi in read/write mode. Now, you can recover Raspberry Pi password by changing it. Type the below line of command:

passwd pi

Follow the instructions on the screen and reset Raspberry Pi password.

When you recover your Raspberry Pi login password, enter the commands below:

sync

exec /sbin/init

Raspberry Pi login password

Now, wait until your Pi comes back to the normal command line prompt mode after reboot.

Shut down your Raspberry Pi and unplug the power source.

Step-5: Reset the text file

It is the time to recover the original command text file that you edited in step 2.

Insert the SD card in the card reader slot of your PC, open the ‘cmdline.txt’ file and remove the added code ‘init=/bin/sh’ from it.

Remove the SD card from the computer and attach it to your Pi. Reboot the Raspberry Pi and use your recovered Raspberry Pi password.

Conclusion

Raspberry Pi is useful in making a tremendous number of electronics projects. It can be used to create a home security system or to make a web server for your client PC. It can help to create a temperature control sensor or can make a full-blown Alexa-enabled Eco device. Any SBC thing you think and the Raspberry Pi is there to help to make it possible. And so keeping your Raspberry Pi secured and updated is always recommended.

Even if you did not forget Raspberry Pi password, you should frequently change it to save it from the hackers and unwanted authentication.

Pi Rocks!

Leave a Reply

Your email address will not be published. Required fields are marked *


Download Raspberry Pi Project Guide For FREE

Enter your Name and Email to get 20 Project Ideas right now.