I'm trying to have my computer automatically log in as a specific user after reboot on an Arch Linux machine. I followed the guide from the Arch Linux Wiki, ran # systemctl edit getty@tty1 and pasted the following lines:

ExecStart=-/usr/bin/agetty --autologin username --noclear %I $TERM

This works and I'm automatically logged in and everything. However, when I press CTRL+D to log out because I want to log in as someone else, autologin is triggered and I'm immediately logged back in. How can I configure autologin to only automatically log me in the first time after boot and do nothing when I manually log out?


This is what I currently use:

  1. # systemctl edit getty@tty1, but run a custom script instead:

  2. cat /home/[USER]/.tty1:

    date &> /run/user/1000/tty1started
    if [ -f /run/user/1000/tty1started ]  ; then
      /usr/bin/agetty --noclear tty1 $TERM 
      /usr/bin/agetty --autologin p --noclear tty1 $TERM

    (make sure to chmod +x your script)

The date is because I also use this for other stuff, but the check actually only verifies file existence (touch would suffice). The file is written to RAM (in /run) so its automatically deleted.


  • Change 1000 for your user id (id -u)
  • I do get some pam and ioctl warnings, but everything works fine

as far as i know agetty hasnt got that feature. So you would have to do it by yourself for example with a bash/perl/whatever script that saves a state if there was a previews login for this boot (directory restarted after reboot somehow) and then start the matching getty.

the question is if you really need to do that work, you can also just change to tty2 (using alt+F2) and login there as usual.



Lateral answer: In addition to switching to another tty (as described in treaki's answer), you could substitute the new user for your current user

su otherusername

When you log out of otheruser's shell, you will return to your session.

(Some believe su is for switching to the superuser account. Actually, it's "substitute user", to allow issuing commands as a different user. If you are not logged in as root, when you emit the su otherusername command, you will be prompted to provide otheruser's password. Note that su does not run the normal .profile or shell resource scripts; it leaves your current working directory and environment variables alone in a new shell run by otheruser. If you need a full login session, use the hyphen option with su:

su - otherusername


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.