When I open a terminal emulator (xterm for example), xterm will have a master end (/dev/ptmx), and a slave end (/dev/pts/#).

But what about when I open a virtual terminal (by pressing Ctrl+Alt+F#), is the virtual terminal also connected to a master? or is it directly connected to a slave (/dev/tty#) without a master?


There is no master (and therefore it is not a slave either).

When you're using xterm, the xterm process does the job of translating between keypresses and pixels on one end, and emulated serial port byte stream on the other end. The kernel relays stuff back and forth to xterm through the pty master.

When you're using tty1, the kernel is doing all that stuff itself. The code in drivers/tty/vt/keyboard.c interprets keypresses, and drivers/tty/vt/vt.c interprets output. All the logic in xterm to implement VT100-like behavior is replicated there.

Since this implementation is in the kernel, it can talk directly to the relevant lower-level drivers (GPUs, the USB bus where your keyboard is, etc.) without relaying through a userspace process. Without another userspace process being involved, there's no need for a "master end" of the tty.


At that point, both "yes, there's a master" and "no, there's no master" are correct, because you're into semantics.

Yes, there's a master: the console driver itself. The character codes the slave end sees and sends bear somewhere between very little and no relation to what's really going on with your keyboard. The real hardware is going through many layers of redirection and reinterpretation and rerender to present the illusion of mid-'80s hardware.

No, there's no master: masters have programmatic control over what the slave end sees, and you can't do that without literally replacing the relevant part of the kernel. You can run loadkeys to control how keystrokes are interpreted, but no ordinary program can insert itself into the dataflow.


Be careful about terminology: there are two different ways in which a terminal can be called “virtual” here.

A terminal emulator creates a virtual terminal, but it isn't usually called “virtual terminal”, but pseudo-terminal. The terminal emulator opens /dev/ptmx and gets the terminal interface of the terminal (called “master end”); applications running in the terminal use the application interface of the terminal in /dev/pts (called “slave end”).

What Linux calls “virtual terminal” (vt) is also called a console. It's virtual because there are multiple vt's sharing the same keyboard and screen. Here there isn't a concept of master and slave device, because there's only one device, for the application side. The terminal side is handled internally by the kernel (you could say that the master end is hidden inside the kernel).

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.