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]
[Single user mode] When you lost the root or pi password
Last edited by Roos Lee on Mon Nov 30, 2015 5:16 am, edited 1 time in total.
Re: [Single user mode] When you lost the root or pi password
Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.
Re: [Single user mode] When you lost the root or pi password
Step 5 is not required. You are already logged in as root.
- DougieLawson
- Posts: 42480
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: [Single user mode] When you lost the root or pi password
With NOOBS you can use the recovery system config editor to add the single user mode "rw init=/bin/bash" stuff.AndyD wrote:Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: [Single user mode] When you lost the root or pi password
I thaught i it was possible to hold shift and boot a 'recovery mode' [1] [2] kernel ect .DougieLawson wrote:With NOOBS you can use the recovery system config editor to add the single user mode "rw init=/bin/bash" stuff.AndyD wrote:Please note this only works for Raspbian boot images, it won't work if you are using NOOBS to boot into Raspbian.
-edit-
[1] how-to-force-recovery-mode-being-entered-on-boot-overrides-gpio-or-keyboard-input
[2] Help with getting to Noobs recovery
- DougieLawson
- Posts: 42480
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: [Single user mode] When you lost the root or pi password
The NOOBS recovery system has a config editor, I've never used it - none of my RPis run NOOBS.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
-
- Posts: 4277
- Joined: Sun Jan 15, 2012 1:11 pm
Re: [Single user mode] When you lost the root or pi password
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
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)
(One of the best lines I've seen on this board lately)
-
- Posts: 1
- Joined: Sat Aug 29, 2020 8:19 pm
Re: [Single user mode] When you lost the root or pi password
Thank you for posting this. I accidentally messed up file permissions on Raspbian, which caused it to not boot properly. I was able to fix it with all data intact by using this tutorial and a bit of some experimentation and troubleshooting to change the permissions of the folder that I accidentally changed to no longer work correctly.
Thank you for posting this tutorial, it helped save me from losing everything I had on my Raspberry PI.
Thank you for posting this tutorial, it helped save me from losing everything I had on my Raspberry PI.