All Raspberry Pi OS systems are installed with the same user and password (pi / raspberry). This is very convenient when you install it, but it can lead to security issues. Also, you may want to change your password regularly for security reasons. Here is how to do this.
On Raspberry Pi OS with Desktop, the password can be changed via the Raspberry Pi configuration tool in the main menu. And on Raspberry Pi OS Lite or SSH, the command to change the password is “passwd”.
For more information, keep reading. I’ll explain the step-by-step process to change your password in each case.
I’ll also provide a guide on what to do if you have lost your password.
Change password on Raspberry Pi OS with Desktop
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
If you are on Raspberry Pi OS with Desktop, it should be pretty easy to change the password. I have included photos with the step-by-step guide below to help you with this procedure.
By the way, you absolutely need access to a session on Raspberry Pi OS to do this. If you have lost your password, check the last part of this tutorial before getting started below.
Before going further, I want to remind you that the welcome wizard on Raspberry Pi OS is a pretty neat tool that allows you to change many things, including the password for the “pi” user.
That’s almost the first question it will ask you:
If you are just installing your system, this is the easiest way to change your password. Follow this wizard, set a password, and configure the basic settings.
Raspberry Pi Configuration tool
There is a good chance you are here because you changed your password during the first boot, haven’t used your password since as the session opens without a password, and don’t remember what password you set.
No worries, you can change your password easily by following these few steps:
- Open the main menu in the top left of your screen.
- Go into Preferences and click on “Raspberry Pi configuration”.
- A window will appear with many settings you can tweak.
Click on “Change password”:
- Then you can change your password directly:
Choose a new password and enter it twice.
If you are doing this for security reasons, I highly recommend using a long password (no need for multiple special characters, but long passwords are better).
For example, I often use that kind of tool that generates long passwords that are easy to remember.
- Once done, Raspberry Pi OS will display a success message:
That’s it! You have now changed your password, and can proceed with whatever you were trying to do :).
By the way, if you are just getting started on Raspberry Pi, I can help you to learn much faster. My Raspberry Pi boot camp course helps you discover the Raspberry Pi device and unlock its secrets step-by-step. In a few hours, you’ll be ready to start any fantastic project you are interested in.
Change password on Raspberry Pi OS Lite (or SSH)
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
If you just have access to a terminal, via Raspberry Pi OS Lite or remote SSH access, you can’t use the previous tools.
But don’t worry, it’s not very complicated, as there is only one command to remember (and you have the choice).
It’s not the fastest method, but it is definitely the easiest to remember.
Raspi-config is a great tool available on Raspberry Pi OS to configure most settings on your system.
It includes a function to change your password, which is what we will use in this section:
- Open a terminal, connect via SSH or log in on Raspberry Pi OS Lite.
- Start raspi-config with:
Your current password might be required to go further. If you have lost it, check the last part of this guide.
- Go to “System Options” (1).
- Then click on “Password” (S3).
- Confirm by pressing “Enter”.
- Type your new password twice.
- That’s it, you should get a confirmation message now:
- You can exit raspi-config with “Esc”.
So, Raspi-config is pretty convenient to remember, but as I told you there is still a faster solution.
The passwd command
Raspi-config is just a nice interface, running many Linux commands in the background. If you remember this easy command, you can go directly to the last step.
The command line to change a password on Raspberry Pi is:
The good news is that this solution will work on any Linux distribution, even if you are not on Raspberry Pi OS.
A bit lost in the Linux command line? Check this article first, which will give you the most important commands to remember, and a free cheat sheet you can download to have the commands at your fingertips.
If you have any comment, suggestion or just want to chat with us about this tutorial,
you can post your messages in the community on Patreon. See you there!
Recover access if you have lost your password
We have discussed how to change your password if you still have access to the user session. But can you do the same if you have lost the password?
Yes, in fact, there are several solutions.
Use another user
The easiest way is to log in with another administrator user. If you followed my guide on how to create a new user on Raspberry Pi, you can use it to reset the password of another user.
You need the sudo privileges to do this.
The command to change the user password from another session is:
sudo passwd <user>
So, for example:
sudo passwd pi
If you are logged in with another use, you can change it directly and recover access to this session.
Another option could be to change the default username on your Raspberry Pi.
Log in with root
A similar way is to use the root user directly.
If you have allowed it to access SSH, you can follow the same steps as with another user (you just don’t need sudo).
What you can also do, is removing the password requirement on another session. Here is the command to do this:
sudo passwd <user> -d
Once done, you can open a session with this user without any password, and change it following the first part of this tutorial.
Unfortunately, there is no other way. As the root user is not enabled by default, you can start in single user mode or anything like that which I use on Linux from time to time.