💾 Archived View for gemlog.cosroe.com › gogo › technical › chroot.gmi captured on 2023-09-28 at 15:39:20. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
I locked myself out of my laptop. I'd been away for a while and when I got back I spontaneously not only forgot my password but my username as well, which is bad, since the login screen on my arch installation is just a tty.
I had a linux distro on an SD card lying about, which I booted into instead, with the intention of reading the `/etc/passwd` file to discover what my username was. But whilst waiting for the thing to boot, I was searching online to see if anyone had a similar problem and that's when I learned about `chroot`.
From the manpage:
chroot - run command or interactive shell with special root directory
The long and short of it is it lets you change the `/` root of your filesystem for a given shell. So, after mounting the partition of the machine I had forgotten my login for, I could
chroot /mnt passwd root
and change the root password, reboot, and login fine.