How to recover the password of your Raspberry Pi if you lost it. 2018 Update.
ⓘ Cet article peut avoir été partiellement ou totalement traduit à l'aide d'outils automatiques. Nous nous excusons des erreurs que cela pourrait engendrer.
We regularly receive questions from our readers, and some come back relatively often.
This tutorial aims to answer one of this recurring question: I have lost my password, is it possible to recover access to my Raspberry Pi?
The answer can be surprising but it is actually possible to recover a forgottent or lost password on the Raspberry Pi. To be more exact, it is actually possible to change the lost password of your Raspberry Pi.
Step 1: Prerequisites to recover the password of your Raspberry Pi
To be able to change the password of the Raspberry Pi when you forget it you will absolutely need the following things, impossible to do without:
- Physical Access to the Raspberry Pi
- A computer
- A screen to connect the Raspberry Pi (if you dont have one, look for it here)
- A keyboard to plug into the Raspberry Pi (here again, if you dont have one, take a look to this one)
STEP 2: Extract the SD card from the Raspberry Pi
The first step is to turn off the Raspberry so you can remove the memory card without worry.
If the Raspberry Pi is not connected to a screen, the only way to turn it off is to unplug it. Otherwise, you can go through the GUI to turn it off properly, via the menu, before unplugging it.
Once the Raspberry Pi is turned off, you can insert the card into your computer and go to the next step.
STEP 3: Edit the cmdline.txt file
Open the file browser on your computer and go to the memory card. You will find in it a file named
This file should contain a line of text that resembles the line below.
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
You must modify this file so that the Raspberry Pi starts on the
bin/sh script, which will allow you to change the
password of your Raspberry Pi without knowing it!
To do this, simply add the line below to the end of the file and save it.
WARNING: The text must imperatively be on the same line. It is possible that the “block note” editor will display it on the same line while it is not, consider checking with another text editor (eg sublimtext).
STEP 4: Change the password of your Raspberry Pi
Once the file has been modified, you can safely disconnect the memory card from the computer and reinsert it into the Raspberry Pi.
It is in this part that you will need a screen and a keyboard for your Raspberry Pi. So connect your keyboard and your screen to the Raspberry Pi and start there.
A series of command lines should scroll quickly. After a few tens of seconds, the screen will be completely frozen. You should now be able to type text.
We will now mount the root of the system. To do this, run the following command :
mount -o remount, rw /
All you have to do now is to change the password of the Raspberry Pi. To do this, simply type the following command and follow the steps on the screen (note that for security reasons the password may not appear when you type it):
Once the password is changed, run these commands:
sync exec /sbin/init
The Raspberry will go out. Wait until the screen has completely frozen for at least 30 seconds and unplug it!
STEP 5: Revert to the original cmdline.txt
Remove the SD card from the Raspberry Pi and put it back in your computer.
cmdline.txt file again the
init=/bin/sh part you previously add.
Put the SD card back into your Raspberry Pi and restart it. You should now be able to log in with the new password!
Now you know how to retrieve the lost password of your Raspberry Pi and retrieve access to your system!
Do not hesitate to take a look at our other articles, such as our analysis of the official accessories of Raspberry Pi or our tutorial to set up a media center!