5

I've uninstall the GUI, and I also want to disable automatic login at the command line. I've read that you should use the raspi-config utility to do this. I select the first option and reboot, and it has no effect.

How does one "do this manually"?

3 Answers 3

8

Autologin is performed as part of systemd's getty target:

root@raspberrypi:/etc/systemd/system/getty.target.wants# ls -l
total 0
lrwxrwxrwx 1 root root 38 Sep 24 18:14 getty@tty1.service -> /etc/systemd/system/autologin@.service

The raspi-config simply manipulates this symlink. To switch to manual login, execute (as root):

ln -fs /lib/systemd/system/getty@.service \
 /etc/systemd/system/getty.target.wants/getty@tty1.service

To switch back to automatic login, do:

ln -fs /etc/systemd/system/autologin@.service \
 /etc/systemd/system/getty.target.wants/getty@tty1.service

I wanted a system with no console prompt on tty1, so I removed this symlink altogether.

1
  • 3
    If you have removed the default user "pi", you must also update "/etc/systemd/system/autologin@.service". Update the username in the line ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I $TERM.
    – skibulk
    Feb 1, 2016 at 13:59
2

I solved this by looking at exactly what raspi-config does.

sudo systemctl set-default multi-user.target
sudo ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
sudo rm /etc/systemd/system/getty@tty1.service.d/autologin.conf

This is B1 Console in raspi-config. For other alternatives go to do_boot_behaviour in raspi-config source file. To find source file, use:

which raspi-config
0

The autologin process is controlled by getty@tty1.service. And the config file autologin.conf under the folder /etc/systemd/system/getty@tty1.service.d/ is a drop-in file. You can just change the file name to autologin.conf.bak then the username and password prompt will show up on the next boot.

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.