Name

vt — kernel virtual terminal devices

Description

The kernel provides virtual terminal devices as /dev/ttyN where N is from 0 to 63. These are character devices with major number 4 and minor number from 0 to 63. Each is a fully functional terminal device, with a line discipline. It does not support serial device control.

There are 63 kernel virtual terminals, numbered from 1 to 63. The file numbered 0 acts as an alias for whichever virtual terminal device is currently active. Initially, virtual terminal 1 is active.

The kernel creates the internal data structures for each virtual terminal on the fly, as each /dev/ttyN device is first opened. If nothing opens the relevant device file, therefore, the kernel does not allocate any resources for the virtual terminal.

The virtual terminals are managed by a terminal emulator program that (unless configured out) is built into the kernel itself. The emulator program does not run as a distinct process, and uses internal interfaces to the framebuffer and event I/O devices. Applications can take over individual virtual terminals, disconnecting the kernel's built-in terminal emulator from the I/O devices and thereby letting applications handle all I/O with those devices when that virtual terminal is the active one.

The type of the terminal emulated does not closely match any other terminal, although there are borrowings from DEC VTs, ECMA-48, and the Xenix console. Only 256 colours are supported, direct colour being emulated by mapping to the nearest indexed colour; and the DEC VT control sequence conventions for the Home and End keys are swapped with the Find and Select keys.

Hot keys

The user sitting at the keyboard and display can change which is the currently active kernel virtual terminal using hot-key keychords. What the keychords are is programmable by uploading different keyboard maps to the kernel's terminal emulator. By default when no keyboard map has been loaded and conventionally in most keyboard maps, the chord Alt+FN requests a switch to virtual terminal N.

Applications that take over a virtual terminal and do their own HID and display handling, such as xorg(8), have their own hot keys that are not necessarily the same and that are not managed by the kernel. Conventionally but not universally in such applications, the chord Control+Alt+FN requests a switch to virtual terminal N. For convenience, these same chords are conventionally mapped to virtual terminal switch requests in the keyboard map of the kernel's virtual terminal emulator, too.

Such applications can also block hot-key virtual terminal switches, which require their coöperation.

The kernel can be configured with a hot-key sequence in the virtual terminal subsystem (the "Magic SysRq" keys, also mis-named "SAK") that issues a SIGKILL signal to all processes that have an open file descriptor to the currently active virtual terminal device.

See also

console_codes(4)

This describes the input and output control and escape sequences recognized and produced by the kernel's terminal emulator.

console_ioctl(4)

This describes the ioctl() controls that are peculiar to kernel virtual terminal devices.

chvt(1)

a utility that can be used to switch amongst kernel virtual terminals under script control

fgetty(8), agetty(8), mingetty(8)

the family of programs that are usually responsible for first opening kernel virtual terminal device files

Files

/sys/class/tty/tty0/active

The contents of this pseudo-file are the currently active virtual terminal name. A file descriptor open to this file can be polled, and will set POLLPRI when the active device name changes. POLLPRI remains set until the contents of the file are (re-)read.

/dev/vcsN, /dev/vcsaN

The contents of these pseudo-files comprise the character display buffers of virtual terminal N, as explained in vcs(4).

History

A multiple virtual terminal subsystem, with the same hot-key keychords and many of the same control sequences and ioctl()s, first appeared in Xenix in 1985. It was named Multiscreen.

Until Linux version 1.1.54, the list of kernel virtual terminals was fixed (with a length given by the NR_CONSOLES constant in the source code) and data structures were not allocated on demand.

Author

Documentation by Jonathan de Boyne Pollard