systemd – How to Change Default Login tty

systemdtty

I'm running xfce on Arch without a DM. Using xorg-xinit to startx. Per default, after startup, I get a login prompt on tty1 and all is good.

However, I'd like to change the default behavior to be dropped at a login prompt on tty6 (or whatever) without having to manually Ctrl+Alt+F6.

I've spent a bunch of time reading various sources, Arch wiki, man pages, http://0pointer.de/blog/projects/systemd-docs.html, etc.

However, I'm still not getting it.

I've tried both manually adding and deleting the files, /etc/systemd/system/getty.target.wants/getty@tty1.service and getty@tty6.service. Alternatively also used systemctl to enable and disable them.

As a test, also editing last line of /usr/lib/systemd/system/getty@.service DefaultInstance=tty1 to DefaultInstance=tty7, and combinations of all the above. Would have created in /etc/systemd/system if it worked.

I asked on the Arch forums and got one very general reply, mostly crickets chirping. Is what I'm trying to do frowned upon for some reason?

I ended up just creating a service file in /etc/systemd/system that calls a bash one liner with chvt in it. This gives me what I wanted, but now I can't scroll the boot messages I have setup to not clear on tty1. This solution also seems like a bad add on hack.

What would be the proper way to do this?

Best Answer

The DefaultInstance refers to systemd instances of a service not which one should be parent. On many Linux distros including Debian inittab is still what spawns ttys. The service file is there more or less to keep track of it.

Usually the display manager decides the starting tty and spawns one on tty7 or above then switches to it much like chvt. Since you aren't using one xinit DOES NOT spawn a new tty it will only open X on the current TTY. Note that X is usually using tty7 not tty6. You should refer to the Arch Linux wiki here: https://wiki.archlinux.org/index.php/Xinit on how to use xinit.

So your choices are:

  • Use a Window Manager
  • Use multi seat
  • auto login

To put this another way your window manager is what handles session authentication. Without it you rely on the tty as logined in for this purpose. So switching to another requires it also be logged in which case you'd have to switch to it and login anyway (or use autologin) Thats why the display manager is what asks for your login credentials.

Given your setup the proper way would be, you can't switch ttys unless they auto login because startx is tied to the tty unless you reauthenticate which is what a window manager does.

Related Question