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
-
- Posts: 14391
- Joined: Fri Mar 09, 2012 7:36 pm
- Location: Vallejo, CA (US)
Re: Password
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.
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.
-
- Posts: 258
- Joined: Sat Oct 24, 2015 1:50 pm
Re: Password
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
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
Re: Password
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 to the change the password of the user you want to change.
- Barry
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]
- Barry