Running a pi 4 with raspian. I dont have a password fro removing or installing software.
How do I reset it without having to delete everything and start again?
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityRunning a pi 4 with raspian. I dont have a password fro removing or installing software.
How do I reset it without having to delete everything and start again?
If you have root on another linux box and an SD card reader, you can mount the SD card from the pi on that machine, and copy your hashed password from the local machine to the SD card.
You will find your local password in /etc/shadow as the second :
separated field, or you can generate a new one with tools like htpasswd
or openssl passwd -6
When you mount the SD card, the shadow file on the SD card would be something like /media/root/etc/shadow
Be sure to correctly eject the SD card before removing it.
Rebooting to a root shell and can repair most problems on the Pi.
init=/bin/sh
at the end of cmdline.txt
and reboot.mount -n -o remount,rw /
You can then reset password with passwd pi
although there are other methods e.g. deleting the password in /etc/passwd
(which you will find if you search)
init=/bin/sh
and reboot.Some addition to @milliways's answer:
cmdline.txt
cmdline.txt
is on the first partition (or /boot
)pi ALL=(ALL:ALL) NOPASSWD: ALL
at the end of /etc/sudoers
temporarily, assuming that you can mount the second partition somewhere.