Roos Lee
Posts: 4
Joined: Mon Jul 20, 2015 1:27 am

[Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 5:02 am

Please follow below sequences

1. Power down and pull the SD card out from your Pi and put it into your computer.

2. Open the file 'cmdline.txt' and add 'rw init=/bin/sh' to the end. This will cause the machine to boot to single user mode.
(-------> Then, maybe 'cmdline.txt' will be changed 'dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait rw init=/bin/sh')

3. Put the SD card back in the Pi and boot.

4. When the logs stop to come up, press 'enter'

5. Then the prompt comes up, type 'su' to log in as root (no password needed).

6. Type "passwd pi" and then follow the prompts to enter a new password.

7. Shut the machine down, then pull the card again and put the cmdline.txt file back the way it was by removing the 'rw init=/bin/sh' bit.

That' all. If you insert just 'init=/bin/sh', it has just read permission, so you should add 'rw' in front of 'init=/bin/sh'

The most important thing is 'Don't abuse this method!!' Please!!
Thanks!!





ref : http://www.mapledyne.com/ideas/2015/8/4 ... spberry-pi
[/size]
Last edited by Roos Lee on Mon Nov 30, 2015 5:16 am, edited 1 time in total.

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 5:15 am

Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.

User avatar
rpdom
Posts: 17214
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 6:32 am

Step 5 is not required. You are already logged in as root.

User avatar
DougieLawson
Posts: 39192
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 11:30 am

AndyD wrote:Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.
With NOOBS you can use the recovery system config editor to add the single user mode "rw init=/bin/bash" stuff.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
r3d4
Posts: 983
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 11:41 am

DougieLawson wrote:
AndyD wrote:Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.
With NOOBS you can use the recovery system config editor to add the single user mode "rw init=/bin/bash" stuff.
I thaught i it was possible to hold shift and boot a 'recovery mode' [1] [2] kernel ect .

-edit-

[1] how-to-force-recovery-mode-being-entered-on-boot-overrides-gpio-or-keyboard-input

[2] Help with getting to Noobs recovery

User avatar
DougieLawson
Posts: 39192
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 2:33 pm

The NOOBS recovery system has a config editor, I've never used it - none of my RPis run NOOBS.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: [Single user mode] When you lost the root or pi password

Mon Nov 30, 2015 3:20 pm

I've never had to include the "rw". I don't think it is necessary (Yes, I have been able to modify the files perfectly fine). Maybe it is necessary in the brave new world (I've not had to do this in Jessie yet).

Also, it is probably better to use /bin/bash instead of 'sh' - you'll be glad you did.

Also, the instructions are a little light on the "Shut the machine down" part. Note that the usual methods don't work, because they all use "init" (again, this may not apply in the brave new world). I think the best way to continue on after you're done fixing things is: exec /sbin/init
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

Return to “Troubleshooting”