-1

A newbie error I made when changing /etc/X11/Xsession.d/99qt5ct stopped my Pi 4 booting without a password. Which of course I have forgotten/lost!

From what I could find searching, most of the info on changing cmdline.txt in boot relates to the earlier Pi's and not the 4.

Do I understand correctly: the Pi 4 has some of the boot info, including the root password held on the SOC? And if correct - is there a way to change it?

Darth Vader
  • 4,206
  • 24
  • 45
  • 69
forestDM
  • 21
  • 1
  • 7
  • 1
    Raspberry Pi OS (like most Debian OS) does not have a root password. The OS behaves the same on all Pi. – Milliways Jun 25 '20 at 13:03
  • Do you set a password for user root by yourself? – Ingo Jun 25 '20 at 16:56
  • Yes. I did change the "Pi" password - some time back. That is the one I have forgotten. I have attempted modifying the cmdline.txt. Inserteing init=/bin/sh after rootwait. The result was the usual stream of text as the OS loaded but that stopped with a flashing "-" and no option to enter text – forestDM Jun 26 '20 at 09:11
  • Maybe of use: https://unix.stackexchange.com/a/168422/25985 – goldilocks Jun 26 '20 at 14:46
  • Did that "stream of text" contain any error messages? – Dmitry Grigoryev Nov 26 '20 at 08:00
  • This all happened back in June. Since when I have reverted to a fresh install and this time kept a note of my PW – forestDM Nov 27 '20 at 00:19

2 Answers2

0

If you haven't changed your password before then your password may be raspberry which is the default password for user pi.

If you want to change the default password then use passwd command. Documentation link.

0

including the root PW held on the SOC

Technically passwords are not stored anywhere. Point being, if you have privileged access to the root filesystem, you can remove or replace a password without having to know what it is, and without the system running (eg., if you put the SD card in another computer):

How can we change root password?

However, there is no means of recovering a forgotten password because, once again, it isn't actually stored anywhere.

Raspberry Pi OS (like most Debian OS) does not have a root password.

To elaborate on some of the material from the other links and clarify a possible point of confusion, there are two "user with no password" scenarios, depending on what's in /etc/shadow.

The default entry for root on Raspbian/RpiOS:

root:*:18297:0:99999:7:::

The second field is an asterisk, and as per man 5 shadow, "the user will not be able to use a unix password to log in" (and there are no other ways to log in on a default Pi). However, if the second field were empty:

root::18297:0:99999:7:::

Then "no passwords are required to authenticate as the specified login name" (just hit enter when asked for one). This is the trick used in the Unix & Linux exchange answer linked above.

goldilocks
  • 58,859
  • 17
  • 112
  • 227