-
- Posts: 4
- Joined: Fri Oct 19, 2012 1:17 am
Reset OS password
Hi all,
I'm new to the raspberrypi and to linux both. I setup the os yesterday complete with password and wrote the information down. Today when I tried to log into the os, I could not get it to work. How can I get the password changed so I can use the computer?
Thanks
Paul
I'm new to the raspberrypi and to linux both. I setup the os yesterday complete with password and wrote the information down. Today when I tried to log into the os, I could not get it to work. How can I get the password changed so I can use the computer?
Thanks
Paul
Re: Reset OS password
I'm sure one of the experts will have a better way to do this, but ...
If you have access to a computer with an SD card reader you can edit the cmdline.txt file and add this to the end of the line:
(it would probably be a good idea to save a backup copy of the cmdline.txt file first)
Then put the SD card back in the Pi and boot. You should arrive at a shell prompt # (you may need to press Enter for it to show up when it's done booting).
To change the password for the default user ("pi"):
You will be prompted to enter the new password twice.
Then turn off the pi, move the SD card back over to the computer and remove the init=/bin/sh parameter from the cmdline.txt file (or restore from backup).
reference: http://www.raspberrypi.org/phpBB3/viewt ... 12#p109612
If you have access to a computer with an SD card reader you can edit the cmdline.txt file and add this to the end of the line:
Code: Select all
init=/bin/sh
Then put the SD card back in the Pi and boot. You should arrive at a shell prompt # (you may need to press Enter for it to show up when it's done booting).
To change the password for the default user ("pi"):
Code: Select all
passwd pi
Then turn off the pi, move the SD card back over to the computer and remove the init=/bin/sh parameter from the cmdline.txt file (or restore from backup).
reference: http://www.raspberrypi.org/phpBB3/viewt ... 12#p109612
-
- Posts: 4
- Joined: Fri Oct 19, 2012 1:17 am
Re: Reset OS password
Thanks for the replays.. I am totally out of my knowledge lever here. I tried to find the line to change on my pc with no luck.. would I be able to change that line if I tried to find it on a Mac? My son has a mac but he wouldn't be around til Saturday.
Re: Reset OS password
Assuming you're using Raspbian wheezy, there's only one line in the cmdline.txt file. When you insert the SD card in a Windows machine a window normally pops up and asks if you want to open the folder to view the files. In the resultant window you should see a text (.txt) file named cmdline or cmdline.txt ... you can right-click on that and select Open with -> Notepad.
It normally looks like this:
And you'd change it to this (the only change being the addition of init=/bin/sh at the end):
(your browser is most likely wrapping the text to multiple lines, but it's really just one line)
You should be able to edit the text file on a PC or Mac. When you're done resetting your password you just change it back.
It normally looks like this:
Code: Select all
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Code: Select all
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh
You should be able to edit the text file on a PC or Mac. When you're done resetting your password you just change it back.
-
- Posts: 4
- Joined: Fri Oct 19, 2012 1:17 am
Re: Reset OS password
Ok I did find the command lone and made the addition at the end. Then booted the system up and now I am back at the raspberry login. what should I type in there to start the password change?
Re: Reset OS password
If you're at the # prompt, just:
Code: Select all
passwd pi
-
- Posts: 4
- Joined: Fri Oct 19, 2012 1:17 am
Re: Reset OS password
Hi Bill, Thanks for your help. I have changed the command line but the bootup goes all the way to login name and password not the # prompt. I have checked the command line and everything is the same as the one on the reply including the int addition.
the linux I am using is debian that is on the 4gig MC.
Paul
the linux I am using is debian that is on the 4gig MC.
Paul

Re: Reset OS password
Hmm... not sure why that isn't working, then. I tested it on my RPi running the Raspbian wheezy 09-18-12 and was able to change my password that way (pretending I forgot it).
I'm assuming you got the card with Debian pre-installed along with your RasPi ... ? At this point it might be easier just to download the latest Raspbian image (here) and overwrite your SD card (you would lose anything previously saved to it, though). It's a fairly easy process -- you just want to make sure you select the correct drive letter when using Win32DiskImager. I've been using the 0.5 release on Windows 7.
I'm assuming you got the card with Debian pre-installed along with your RasPi ... ? At this point it might be easier just to download the latest Raspbian image (here) and overwrite your SD card (you would lose anything previously saved to it, though). It's a fairly easy process -- you just want to make sure you select the correct drive letter when using Win32DiskImager. I've been using the 0.5 release on Windows 7.
Re: Reset OS password
Hello,
I am experiencing exactly the same problem however I downloaded a new version of the OS onto a different card and this one wont boot at all. Do you need to do anything to make the card active?
I am experiencing exactly the same problem however I downloaded a new version of the OS onto a different card and this one wont boot at all. Do you need to do anything to make the card active?
Re: Reset OS password
Hi,
I had a similar problem that I forgot my password. At first the solution mentioned to edit the file and add 'init=/bin/sh' did not work for me either. I think this was because Shell (which is what i think the line init=/bin/sh is initiating) didnt understand my wireless logitech keyboard, I couldnt type anything. I switched to a wired usb keyboard and the PI booted so I could reset the password.
Hope this post helps.
Andrew
I had a similar problem that I forgot my password. At first the solution mentioned to edit the file and add 'init=/bin/sh' did not work for me either. I think this was because Shell (which is what i think the line init=/bin/sh is initiating) didnt understand my wireless logitech keyboard, I couldnt type anything. I switched to a wired usb keyboard and the PI booted so I could reset the password.
Hope this post helps.
Andrew
Re: Reset OS password
I had the same problem. I wasn't seeing the shell prompt, but instead the pi gave me the login prompt There is a difference in the way windows and Linux represent a new line and the text needs to be exactly one line apparently, so when working on windows you must put the cursor at the end of before the empty space. Then hit space and enter . That fixed my problem and let me see the shell prompt - #.
Code: Select all
rootwait
Code: Select all
init=/bin/sh
Re: Reset OS password
Sorry for posting on a older forum but I have forgotten my password and I am trying to get into bash on my pi.
I have eddied the cmdline.txt file and I keep getting the same thing - the raspberry pi login prompt.
Any ideas anyone? I know it could just be where I put the init/bin/sh
Thanks
I have eddied the cmdline.txt file and I keep getting the same thing - the raspberry pi login prompt.
Any ideas anyone? I know it could just be where I put the init/bin/sh
Thanks
Re: Reset OS password
Hi. I did this cmdline.txt fix, but got sent right back to the login line when I powered up. I did not get a # prompt. However, I was able to login with "pi" as the user and "raspberry" as the password. Once in, I easily reset my password. Hope this helps.
Re: Reset OS password
In my case, I didn't forget the password. I actually stumbled upon a tricky raspi-config design bug. More details on what it is and how to work around it here: http://computerstruggles.blogspot.com/2 ... onfig.html
-
- Posts: 1
- Joined: Mon Dec 16, 2013 9:38 pm
Re: Reset OS password
One of the easiest methods, provided you have another working Linux distro (that you can log into) is to simply copy the password hash from the user you've just logged in and overwrite the one from your rPI. That's located in /etc/shadow in one of the automatically mounted partitions of the SD card. And voila, you can login into your rPI with the same password you've logged in the other linux distro. Enjoy!
- williamhbell
- Posts: 291
- Joined: Mon Dec 26, 2011 5:13 pm
Re: Reset OS password
If your system is setup to login automatically, you can
and put a new password, without having to give the previous one.
Regards,
Will
Code: Select all
sudo passwd pi
Regards,
Will
Re: Reset OS password
I tried adding init=/bin/sh
Iam getting an error :
/bin/sh : cant access tty job control turned off
What should I do ?
Iam getting an error :
/bin/sh : cant access tty job control turned off
What should I do ?
Re: Reset OS password
Press the Enter key and see if you get a "#" prompt.
Re: Reset OS password
No I am not getting a # prompt. In fact the keyboard is not working at all. I can see a cursor, but when I press Enter nothing happens. When I press Ctrl+Alt+Del reboot doesnt happen.rpdom wrote:Press the Enter key and see if you get a "#" prompt.
Re: Reset OS password
When I edited config.txt my Pi would not boot, it hung part way through the boot process.
Here's how I got it sorted.
I put the SD card in my Linux laptop and edited /etc/shadow.
I already had an entry for myself in it so I did two things.
First I slightly changed my name in the entry.
Second I then copied and pasted the line from my laptop to the end.
After this I edited /etc/sudoers and added an entry for myself with the same permissions as the pi user.
I put the card back in my pi and rebooted it, logged in as myself and did:
sudo passwd pi, changed the password for pi and rebooted.
I logged in as pi and undid the changes I had made to /etc/shadow and /etc/sudoers.
Back to normal now.
If you don't have an entry for yourself in /etc/shadow then you just miss out that part and it will still work.
Here's how I got it sorted.
I put the SD card in my Linux laptop and edited /etc/shadow.
I already had an entry for myself in it so I did two things.
First I slightly changed my name in the entry.
Second I then copied and pasted the line from my laptop to the end.
After this I edited /etc/sudoers and added an entry for myself with the same permissions as the pi user.
I put the card back in my pi and rebooted it, logged in as myself and did:
sudo passwd pi, changed the password for pi and rebooted.
I logged in as pi and undid the changes I had made to /etc/shadow and /etc/sudoers.
Back to normal now.
If you don't have an entry for yourself in /etc/shadow then you just miss out that part and it will still work.
There are few rewards greater than accomplishing a difficult task. Just because something doesn't cost money doesn't mean there is no cost. Every success makes the next one easier. Of course that takes determination and patience.
Re: Reset OS password
If, like me, you screwed up your Raspberry Pi and need to get into single-user mode, you probably found your way here via Google. I put a bad file in my /etc/sudoers.d directory, and couldn't use the sudo command any more. I was hooped! I tried the instructions above, but like other people (see above) I found that my pi would not boot into single user mode. If I used the "init=/bin/sh" parameter it went through the normal process up to the point where the keyboard and trackball were detected, and then froze (you may see a console message from /bin/sh about no job control).
Maybe the suggested solution worked with an earlier version of the software, or maybe it works with different keyboards, but it didn't work for me. If you are having the same problem, don't worry, there is a solution:
Maybe the suggested solution worked with an earlier version of the software, or maybe it works with different keyboards, but it didn't work for me. If you are having the same problem, don't worry, there is a solution:
- Power up your pi and boot into the NOOBS recovery environment by holding down the SHIFT key when you see the Raspberry Pi logo and the instruction to press SHIFT.
- Highlight the installed OS (I was using Raspbian). The Edit Config button should now be enabled.
- Click the Edit Config button, and select the tab for cmdline.txt.
- At the end of the line (right after "rootwait"), add a space (" ") and the digit "1". This will tell the kernel to boot to runlevel 1 (single user mode). Although it looks like there are multiple lines in cmdline.txt, there is really only one line that is folded. Don't put the "1" on a new line!
- Click the OK button, then click the Exit button to leave Recovery environment.
- Your pi should now boot into single-user mode. You will see a prompt like: root@hostname ~ #. Make the changes you need to fix your problem. Be careful, because you are now the root user!
- Use the "exit" command to leave single-user mode, and continue the boot process to multi-user mode.
- If everything is working correctly again, you should edit /boot/cmdline.txt to remove the "1" that you added to the end of the line. If you don't, the next time you boot your pi it will return to single user mode.
-
- Posts: 1
- Joined: Sat Sep 27, 2014 5:09 am
Re: Reset OS password
I got it to reset my password but I must have a bad username. How do we reset the username?
- DougieLawson
- Posts: 42483
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: Reset OS password
useradd & userdelJustinhultz wrote:I got it to reset my password but I must have a bad username. How do we reset the username?
Add a new id, delete the "bad" one.
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: Reset OS password
For those that reported that the 'init=/bin/sh' method didn't work, 2 scenarios:
1st:
Like described by Alex63, it freezes mid-boot. Just press Enter, the root prompt will show. Then follow the rest of the instructions.
2nd:
It boots to normal prompt. It happened to me too. Simply explained, the text you entered is in the next line and it shouldn't. That's because I used Windows' Notepad and Notepad doesn't interpret the End-Of-Line (EOL) character of the cmdline.txt correctly and shows everything in one line (text files generated in Windows systems use the CR+LF character sequence, those generated in UNIX-like systems use only the LF character).
To edit correctly, either do it on another UNIX-like system (eg, other Linux system) or use Notepad++ (http://notepad-plus-plus.org/) in Windows to edit, it will interpret correctly the text file and maintain the correct structure. After that it might happen the 1st scenario when you boot but it's easy then.
Hope this helps.
Regards.
1st:
Like described by Alex63, it freezes mid-boot. Just press Enter, the root prompt will show. Then follow the rest of the instructions.
2nd:
It boots to normal prompt. It happened to me too. Simply explained, the text you entered is in the next line and it shouldn't. That's because I used Windows' Notepad and Notepad doesn't interpret the End-Of-Line (EOL) character of the cmdline.txt correctly and shows everything in one line (text files generated in Windows systems use the CR+LF character sequence, those generated in UNIX-like systems use only the LF character).
To edit correctly, either do it on another UNIX-like system (eg, other Linux system) or use Notepad++ (http://notepad-plus-plus.org/) in Windows to edit, it will interpret correctly the text file and maintain the correct structure. After that it might happen the 1st scenario when you boot but it's easy then.
Hope this helps.
Regards.
-
- Posts: 1
- Joined: Mon Apr 27, 2015 4:47 pm
Re: Reset OS password
If like me you didn't really have anything saved all you need to do is completely reboot your system.