How I got autologin working

    It's a long story, but at the end of the day, I wanted a little raspberry pi 4B, to auto login and run a script (on the console only).

    This is how I got it going.

    First, I modified root's .bashrc file to have this line that runs a script when I login on the console.

      # If I'm on the console then run the scrip
      [ `tty` == /dev/tty1 ] && /root/

    Great. I can test that it works, and it does.

    Next, in the directory /etc/systemd/system/getty@tty1.service.d The directory may or may not exist, so create it if needed.

    Then create I create a file called override.conf in that directory, with the following content.

      ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux

    I can test is the auto login works (without rebooting), by executing the commands:

      systemctl daemon-reload
      systemctl restart getty@tty1.service

    If that all works, then it's time to reboot … and hopefully, job done. I but no, it's broken. Back to the drawing board :(

    If you webmention this page, please let me know the URL of your page.

    BTW: Your webmention won't show up until I next "build" my site.

    Word count: 200 (about 1 minutes)


    Updated: 20 Dec '23 19:56

    Author: Peter Smith


    Section: blog

    Kind: page

    Bundle type: leaf

    Source: blog/2023/12/20/how-i-got-autologin-working/