forgot raspberry pi password

5 Easy Ways to Reset a Forgotten Password on Raspberry Pi

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

I set up Raspberry Pi systems all the time, so I know how it feels when you forget a password. If you’re stuck at login right now, don’t worry. I’ve got a few reliable ways to reset your Pi password and get back in fast.

Raspberry Pi OS has auto-login enabled by default, so most of the time, you can get access to the main user session without typing any password, and reset user passwords from there. If this isn’t possible, you can edit the /etc/passwd file to allow users to sign in without a password.

I’ve listed five ways to reset your Raspberry Pi password, from the simplest to the trickiest. Try the first one and then keep going down the list until you find the one that works for you. One of them should do the trick.

If you’re feeling lost in all the Raspberry Pi jargon, I’ve got something to help you out. I’ve created a free glossary that explains all the essential terms and abbreviations in a way that’s easy to understand. It’s a great resource to have by your side. Get your free copy here.

1 – Change Password via Control Centre or raspi-config

Use this method if you have a desktop environment and the session opens automatically on boot. In this case, you can directly change the password, without knowing the old one.

Once the GUI loads, go to main menu > Preferences > Control Centre.
Under the System tab, you’ll see a button to change the password for the current user:

It will ask you for a new password, without having to type the current one:

pi configuration change password prompt

So, this solution works even if you don’t know the current password. It’s perfect if you’re still able to get into your system, but have no idea which password to type when the system asks for more permissions (when you install new applications, for example).

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now

If you’re on Raspberry Pi OS Lite instead, you can use raspi-config to change the password from the command line. You’ll find the “Change password” item under the “System Options” section.raspi-config change password option

The most recent Raspberry Pi OS update now separates desktop and console logins, so this might be helpful to you as well.

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In

But if you’re still stuck at the login page, this method won’t help. But I prefer starting with the easiest solution first, so that you don’t break your system if there’s no need to :-). Check the next sections if this method didn’t work for you.

Related: 3 Ways to Remove Password on Raspberry Pi (+Security tips)

2 – Log In With Another User to Change the Password

Use this method if you’ve created several users on your system but lost the password for only one of them. If other users have administrator privileges, they can reset any user’s password on Raspberry Pi.

Even if you only created one user when first installing Raspberry Pi OS, you can easily create new users for different roles and tasks—or even set a password for the administrator account (root).

If you had other users set up on the system where you forgot the password, you might be in luck! If you can access your system with another account that can use the sudo command, you can elevate to administrator permissions and reset the password:

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now
  • Get access to the command line (open a terminal, log in on Lite, or use SSH).
  • Type the following command:
    sudo passwd <username>
    For example:
    sudo passwd pat
  • You should get a prompt to set a new password for this user.
    sudo passwd reset
  • Once done, you can log out and sign back in with the username and password you just set.

It only works if you’ve created other users beforehand. If this isn’t the case on your system, take a look at the next option, which is the last “easy” solution before we start editing files manually.

3 – Use an SSH Connection to Access Your Account

Use this method if you can still connect to your Raspberry Pi via SSH because the password was saved on your client (or you use SSH keys). In this case, you can reset the password via SSH.

If, like me, you’re using a smart SSH client (I use Termius) which saves all session credentials, you almost never type your password. And when you finally need it to install new applications, you might get stuck, as you don’t remember what the password was.

termius ssh raspberry pi

It would be the same if you created SSH keys to log in from other computers without password authentication. In this case, you can still access your account on the Raspberry Pi, but you have no idea what the password is.

Well, this is still an easy solution, as you can use the same command to reset the password as in previous solutions. Use raspi-config or type the following command to set a new password:
sudo passwd pat

Now that we’ve explored all the easy solutions when you still have a way to access your system, what can you do when you’re stuck on the login page with no clue what the password is? Our next two solutions will help you with this.

4 – Clear the Password From Another Linux System

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

If you can access your SD card from another Linux system, you can edit the /etc/passwd file to allow you to log in without a password. Use this method if you can’t access the current system but can boot from another SD card or USB key.

So, if you have a computer running Linux, just plug your SD card into it, and follow the instructions below.

However, if your computer is running Windows instead, you can’t edit the files on the SD card directly. In this case, your best option is to start the Raspberry Pi with another boot media, and follow the instructions from there.

Since I have Windows on my main computer, I decided to use a USB drive with Manjaro installed on it. I booted it on my Raspberry Pi and only plugged the SD card in once logged in to Manjaro. I then follow the instructions below to change the password on the SD card.

manjaro on raspberry pi

Whichever route you choose to get onto a Linux system, the procedure is to edit the SD card and disable the need for a password:

  • Plug the SD card into your computer or Raspberry Pi.
  • Open a terminal.
  • Mount the SD card’s main partition on the current Linux system.
    Some systems will do this automatically for you. On Manjaro, I had to manually enter:
    sudo mkdir /mnt/sd
    sudo mount /dev/mmcblk0p2 /mnt/sd

    Check this article for more details on how to mount drives on Linux.
  • Once the partition is mounted, you can edit the /etc/passwd file:
    sudo nano /mnt/sd/etc/passwd
  • There is one line for each user on your system.
    Find the line corresponding to the user you need to reset the password for.

    For example, if it’s “pat”:
    nano /etc/passwd
  • Remove the “x” between the two colons (:).
    nano /etc/passwd reset passwd
  • Save and exit (CTRL+O, CTRL+X).

You can now halt your current (temporary) system and boot again from the SD card.
(In my case, I shut down the Raspberry Pi, removed the USB key, and left only the SD card.)

On the login screen, you can type the username (“pat” in my example) and it won’t ask for a password. The session will open directly. Now, you can set a new password using Pi Configuration from the GUI, raspi-config, or this command directly:
passwd

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Quick note: If you find it hard to remember all these commands, I’ve put them all on a one-page cheat sheet. You can download it for free here so you have it handy whenever you're working on a project.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Prefer videos over reading? The RaspberryTips Community members get exclusive video lessons every month. Join now and watch them all right away. Get instant access.

5 – Boot in Single-User Mode to Reset the Password (cmdline.txt)

Use this method if all other solutions aren’t available to you. If you only have one SD card or USB key and no other Linux system, this is your best option (not the easiest, but it works).

The idea here is to boot a minimal version of your system with access to the command line as root. This way, you can use it to reset your password.

  • First, insert the Raspberry Pi’s SD card (or USB key) into another PC.
    It can be any operating system (even Windows)—it doesn’t matter.
  • In the boot partition, find the “cmdline.txt” file and open it. It looks like this:
    cmdline.txt password resetYou might have to browse to the /boot/firmware/ folder to locate it.
    I have an in-depth article on this website about cmdline.txt. I highly recommend reading it first, but I’ll give you a summary of how to reset your password here.
  • Add the highlighted text at the end of the line, as in my screenshot:
    init=/bin/sh
  • Save the file, and eject the media.
  • Put the SD card back into your Raspberry Pi, and turn it on.

The system will now boot almost like usual but will stop at a cursor where you can type commands.

  • The partition is not mounted automatically, so you’ll need to do it with:
    mount -o remount, rw /
    Warning: the keyboard layout will be in QWERTY, so good luck if (like me) you use another layout :-).
  • Now that you’re in, you can change the password:
    passwd <username>
    For example:
    passwd pat
    (We are logged in as root, so you don’t need sudo.)
  • Force saving the changes to disk:
    sync
  • Finally, power off the Raspberry Pi (halt and reboot commands won’t work).

Wait, you’re not quite done yet! Before restarting the Raspberry Pi:

  • Put the SD card back into your other computer.
  • Remove the text you added to the cmdline.txt file.
    (So remove “init=/bin/sh” at the end of the line.)
  • Save, and eject the SD card.
  • Put the SD card back into your Raspberry Pi.

On the next boot, use the password you just set, and it should work.

Phew—that’s it! You’re now back in control of your system, so don’t forget your password again :-). And if you want to avoid losing your passwords all the time, you should check out this project (it’s a password manager that you can host on Raspberry Pi).

Whenever you’re ready, here are other ways I can help you:

Test Your Raspberry Pi Level (Free): Not sure why everything takes so long on your Raspberry Pi? Take this free 3-minute assessment and see what’s causing the problems.

The RaspberryTips Community: Need help or want to discuss your Raspberry Pi projects with others who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct help.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts

2 Comments

  1. Patrick, how do you get to pi-config if you can’t log in the first place?

    1. Read the article :-).
      The first 3 solutions only work if you have a way to open a session (auto-login, other account or SSH session saved on your client).
      If not, you can try the two last ones.

Comments are closed.