-1

I'm using Raspbian Stretch Lite. Upon flashing it to an SD card and loading the card into my Raspberry Pi 1 Model A, and turning my pi on, I noticed that its waiting for a user to login before the rest of the OS finishes starting.

Although I can connect this pi to a keyboard and monitor and log in each and every time I want to turn it on, I'd rather the system just log in as the default pi user at startup.

This is because I'll be using my pi on robotics projects, and would like to just turn the pi on and have it launch some startup services without having to connect it to a keyboard/monitor, login, disconnect the keyboard/monitor, and keep going.

So I ask: how do I configure Raspbian to auto-login as the pi user at startup?

  • 4
    Possible duplicate of Auto-login with GUI disabled in Raspbian – Shaulinator Sep 19 '17 at 16:28
  • 3
    Disabling login prompt is an option, but I believe you should review linux a little more. Services can easily be started by the system at boot that do not require a login and can be run under any user. The only thing that is loaded after login is the graphical desktop environment. If your goal is to have programs start at boot, then there is no need to disable login prompt – crasic Sep 19 '17 at 16:29
  • I think this is an XY Problem: meta.stackexchange.com/questions/66377/what-is-the-xy-problem You specified a "solution" rather than the actual problem. Based on what you've said it seems unlikely that automatically logging in is necessary or appropriate. – Brick Sep 19 '17 at 18:03
  • Brick is right; using autologin to run foreground GUI applications is one thing, but doing to run general services is sort of lazy. That's what init is for. – goldilocks Sep 20 '17 at 13:09
5

You could configure the RPi to auto-login as the pi user. You can configure this via sudo raspi-config. To do the same thing manually, create a file /etc/systemd/system/getty@tty1.service.d/autologin.conf containing:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I $TERM

replace pi with the desired existing user account. I have tested this on raspbian jessie and stretch.

Alternately, set your script to run as a daemon using systemd.

  • I think this answers the question asked, but I would highlight the "Alternately" part at the end and also add cron as an option. It's unclear that the OP's actual goal is compatible with the content of the question. Seems like an XY Problem: meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Brick Sep 19 '17 at 18:02
  • cron @reboot is problematic with systemd, based on some admittedly cursory reading. Not sure what you mean about "highlight" @Brick! – bobstro Sep 19 '17 at 18:08
  • I mean cron instead of systemd. If he just wants some script to start at boot, that might be the more appropriate answer. A script running under systemd is supposed to meet some specific unix-defined requirements to how it handles signals, which the OP's probably do not. – Brick Sep 19 '17 at 18:16
  • @Brick please expand on your proposed cron approach. Do you mean @reboot? – bobstro Sep 19 '17 at 18:58
  • Yes, @reboot. OP says "services", but I'm not sure that was used precisely given the rest of the text. Seems OP is happy with your answer though, so I'm moving on. – Brick Sep 19 '17 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.