Changer le mot de passe de la Raspberry Pi quand on l'a oublié

How to recover the password of your Raspberry Pi if you lost it. 2018 Update.

Mis à jour le 14 March 2018 - 4 Commentaires - , , , ,

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 cmdline.txt.

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 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):

passwd pi


Once the password is changed, run these commands:

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.

Edit the 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!

Raspberry Pi FR
Join the Raspberry Pi community
A $35 computer, already sold at 10 millions copies
Related tutorials
Create a Wi-Fi hotspot in less than 10 minutes with Pi Raspberry! Install Android on his Raspberry Pi How to install a web server on the Raspberry Pi (Apache + PHP + MySQL) Create a NAS with your Raspberry Pi and Samba How to Setup a VPN on Raspberry Pi
  1. orducom1 says:

    hi ! i have a problem with this howto …

    i use a pi0 with rasbian minimal install on 4go (class10) sdcard

    when i try your method, it does not work :
    /bin/sh: 0: can’t access tty; job control turned off
    [ 21.366191] random: crng init done

    i try to change password still like this:
    passwd pi
    Enter new UNIX password: (i tape my new password)
    Retype new UNIX password: (again)
    passwd: Authentication token manipulation error
    passwd: password unchanged

    1. Hello, we’ve just updated this how to and it should now be ok.

  2. Peter Rich says:

    Tried your solution to the lost password. Had two problems. Using passwd pi gave error “Authentication token manipulation error”. Mount command gave error “can’t find PARTUUID=8********4-02”

    First error probably caused by failure of second.

    1. Hello, we fixed that trouble. After some returns from our readers we realised that the tutorial was obsolete, but also that it was nearly impossible to find any tutorial for recover a lost password on the raspberry pi who still works in 2018. So we have updated ours to make it working ! Give it another try !

Suscribe to Newsletter
Suscribe to Newsletter
Vous avez aimé cet article ?
Inscrivez-vous et restez informé !