jwwphoto
Posts: 16
Joined: Fri Sep 04, 2015 4:33 pm

Password

Tue Jan 19, 2016 11:35 pm

I changed the default username and password for the Rasbian OS Install on my PI. Is there a way to reset. I am guessing re-writing a new image to card would do it but I would lose my customization I have made to my Raspberry Pi.

I just put is away for about 6 months and can remember what I set it to.


Jeff W Waldrop

W. H. Heydt
Posts: 14414
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Password

Wed Jan 20, 2016 12:30 am

Yes....there is a way, but you need either added software to enable a Windows system to read and write an ext4 file system, or another Linux system (which could be just a "Live CD" running a conventional PC). The following assumes you are using another Linux system (or using your Pi with a different SD card and able to connect the old card at the same time):

You need to gain access to the ext4 partition on the SD card.
Locate the file /etc/passwd. Edit that file.
Find the line that starts with the ID you need to get back into (e.g. the one that starts with "pi").
Remove the 'x' after the first colon.
The line will then start with "pi::".
Save the file.
Do "sync; sync" to flush the buffers.
Unmount the SD card.
Remove the SD card.
Use the SD card to boot the Pi.
The login ID now has no password.
Set a new password.
Done.

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Password

Wed Jan 20, 2016 7:44 pm

No - don't use Windows to mess with that file.

Use the single user mode for Linux by adding "init=/bin/sh" to the text in cmdline.txt in the small boot partition. You can use any other computer, even a Windows one, as it is on a FAT partition, and is a simple text file.

See here for a discussion (somewhat prolonged) about the single user mode - viewtopic.php?p=109612

flubbard
Posts: 65
Joined: Tue Dec 08, 2015 12:41 pm
Location: Ohio, USA
Contact: Website

Re: Password

Wed Jan 20, 2016 8:39 pm

By saying that you changed the default user and password, do you mean that you created a new user...changed the root user password, or changed the password for the pi user?

If you created a new user or changed the root (but didn't change the pi user itself), you could still log on to the pi user, and then

Code: Select all

sudo passwd [username]
to the change the password of the user you want to change.

- Barry

Return to “Beginners”