On Ubuntu Server and Arch I was able to change the following line in /lib/systemd/system/g[email protected]

# Before
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I $TERM


# After
ExecStart=-/sbin/agetty --noissue --autologin john %I $TERM Type=idle

And it works, that it will login to the user john but when I logout of the user john with using exit in the terminal, it logs john back in. Is there a way to change this ExecStart setting to enable auto login for a user on startup but only on startup?

  • @miroslav
    link
    2
    edit-2
    6 months ago

    Try adding these two options to the service

    Type=oneshot
    RemainAfterExit=yes
    
    • @[email protected]OP
      link
      fedilink
      English
      16 months ago

      Changing Type=oneshot and adding RemainAfterExit=yes underneath does not allow me to boot into my system. I get this as the last terminal message

      [ OK ] Reached target Cloud-init target.
      

      No biggie to fix since I did this in a Virtual machine and could restore to an older snapshot.

  • @[email protected]
    link
    fedilink
    26 months ago

    maybe a second service, that when you log in, the service get enabled, and that service block your first service?