Raspberry Pi – Forgot your Pi user Password… Oops

So recently I’ve decided to overhaul my home network, one of the requirements for this is I needed a DHCP and DNS server running, as I had already setup a Raspberry Pi last year with Blynk I decided I could use this for my DHCP and DNS too.

Now the Pi itself wasn’t currently running as my Blynk project is on hold until the summer, booted it up, and even though I ‘know’ the password… it seems I don’t..

Arrghh…

Okay, no big issue. Due the the nature of Raspberry Pi’s its quite easy to reset. Shutdown your Pi, remove the memory card and place this into your PC.

On the Boot drive you should see a file called cmdline.txt, open this file (I used VS Code as notepad sometimes creates side effects). At the end of the line add a space followed by;

init=/bin/sh

Save the file, remove the card and place it back into the Pi. Boot the Pi. Once at the prompt (you are now in single user mode), type:

su

Now at this point you could just type:

passwd pi

to reset the password, but sometimes you need to mount first, so I always do it in this order (including the forward slash, then enter):

mount -rw -o remount / 

Then type:

passwd pi

Follow the prompts.

Shutdown the Pi, take the memory card out and put it back into the PC, edit the cmdline.txt file again and remove the text you put in before, save, and put it back into the Raspberry Pi and boot.

Now you should be able to in as Pi with your new password

Yay.

(Of course this security hack could be done by anyone who has physical access to your Pi…)

 

2 thoughts on “Raspberry Pi – Forgot your Pi user Password… Oops”

  1. This is a great work around, being someone who has a number of Raspberry Pi’s at home, and responsible for even more at work, this is could prove to be a life saver

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: