2

What is this command really doing (step by step)?

openvt -c 40 /bin/agetty tty40 linux

I tried this command instead :

openvt -c 41 /bin/agetty tty40 linux

and agetty was started on tty40 (not tty41). Why is that? It seems the -c 41 option is not necessary. Removing it yields the same result.

1 Answer 1

6
openvt -c 40 /bin/agetty tty40 linux

runs openvt, directing it to use VT 40; so it opens that VT, and runs agetty on it. But specifying tty40 as an argument to agetty tells the latter to use VT 40 (regardless of where it was started), so it opens VT 40 itself and runs there.

Thus,

openvt -c 41 /bin/agetty tty40 linux

opens VT 41, but then agetty opens VT 40 itself.

You should just use one program to open the VT. You can either run agetty directly on whichever VT you want, or tell it to run wherever it’s been started:

agetty tty40 linux
openvt -c 40 agetty - linux

If you remove the -c option, openvt will pick the first available VT.

6
  • Thank you! But if I am on tty2 and I use directly agetty tty40 linux, after I type my username, agetty is replaced by login, which is executed on tty2. Is this expected? How can I use directly agetty in a way that assures that login is executed on tty40 as well?
    – Gradient
    Commented Apr 8, 2017 at 18:20
  • That’s odd; when I tried it, I got the login on the same VT as agetty. This might be a silly question, but are you running agetty as root? Commented Apr 8, 2017 at 18:38
  • I was not. I tried it as root, but I still get the same behavior. When I type my username and Enter, nothing happens on tty40, but on tty2, I am asked for my username, as if agetty had respawned. I am not sure it is the login program actually... It seems like both tty40 and tty2 stopped and tty2 just happened to respawn automatically as it should.
    – Gradient
    Commented Apr 8, 2017 at 18:49
  • Yes, if you’re asked to enter your username again, that’s agetty, not login. (agetty asks for a username, then replaces itself with login to process the login, including asking for a password if appropriate.) Does the second variant work? (openvt -c 40 agetty - linux) Commented Apr 8, 2017 at 18:52
  • Yes, the second variant works. It is weird that the first does not. So, on tty2, agetty tty40 linux is waiting until the command exits. On tty40, after entering my username on tty40, agetty stops and should be replaced by login, but it is not. On tty2, when agetty exits, it is like I exited the shell as well.
    – Gradient
    Commented Apr 8, 2017 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .