How does switching between different sessions with Ctrl+Alt+Fn keys?

tty1 always contains the login screen, and the next free unused tty loads up your actual session. But if I press Ctrl+Alt+F1 , I go to GDM login screen and now if I login to a different account, the session is loaded up on the next free unused tty. So if my first session is on tty2 and second session on tty3 , then I can switch between them with Ctrl+Alt+F2 and Ctrl+Alt+F3 .

How exactly is this switching done under the hood? Through chvt ? or some other mechanism? Include as much technical detail as you can.

1 Like