💾 Archived View for gemlog.cosroe.com › technical › chroot.gmi captured on 2024-06-16 at 12:21:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-10)

-=-=-=-=-=-=-

chroot

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.