1

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:

[Service]
ExecStart=
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?

2

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.

regards

0

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.