Raspberry Pi Reset Forgotten Password

3 min read 1 day ago
Published on Jan 26, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of resetting a forgotten password on your Raspberry Pi. Whether you're using it for personal projects or learning, regaining access to your device is essential. This step-by-step guide will ensure you can unlock your Raspberry Pi efficiently.

Step 1: Power Off Your Raspberry Pi

  • Ensure your Raspberry Pi is completely powered off.
  • Unplug the power supply from the device.

Step 2: Insert the SD Card into Your Computer

  • Remove the SD card from the Raspberry Pi.
  • Insert the SD card into your computer using an SD card reader.

Step 3: Modify the cmdline.txt File

  • Locate the cmdline.txt file on the SD card. This file is usually found in the root directory.
  • Open cmdline.txt using a text editor.
  • Add the following text at the end of the existing line:
    init=/bin/sh
    
  • Save the changes and safely eject the SD card from your computer.

Step 4: Boot Your Raspberry Pi

  • Reinsert the modified SD card back into the Raspberry Pi.
  • Power on the device. It should boot directly into a shell prompt.

Step 5: Remount the Filesystem

  • At the shell prompt, run the following command to remount the filesystem with write permissions:
    mount -o remount,rw /
    

Step 6: Reset the Password

  • To reset the password for the default user (usually pi), enter:
    passwd pi
    
  • Follow the prompts to enter a new password. Ensure it's something memorable but secure.

Step 7: Restore the cmdline.txt File

  • Before shutting down, you need to restore the original cmdline.txt file.
  • Type:
    sync
    
  • Shut down the Raspberry Pi using:
    exec /sbin/init
    
  • Power off the device again and remove the SD card.

Step 8: Finalize Changes on Your Computer

  • Insert the SD card back into your computer.
  • Open cmdline.txt again.
  • Remove the init=/bin/sh text you added earlier.
  • Save the file and safely eject the SD card.

Step 9: Boot Normally

  • Reinsert the SD card into the Raspberry Pi.
  • Power on the device. You should now be able to log in using the new password.

Conclusion

You have successfully reset your Raspberry Pi's forgotten password. Remember to keep your password secure and consider setting up a password manager for future reference. If you encounter issues, revisit each step to ensure everything was executed correctly. Happy computing!