Related to TTY numbers, it looks like there are 64 TTYs (find /dev -name 'tty[0-9]*' | cut -c 9- | sort -n | tail -n 1
and documentation). tty0 is the current virtual console, Ctrl+Meta+F1 reports that it's connected to tty1
, and tty
in a GNOME terminal reports that it's connected to /dev/pts/N
. Only TTYs 1 through 12 can be accessed using the well-known Ctrl+Meta+F* keyboard shortcuts, so what are /dev/ttyN
13 through 64 used for?
3 Answers
Again, as I answered to this question, it is entirely up to whoever sets the system up. Normally only a limited number of getty
s are started, as people nowadays use X instead of a tty (or use screen(1)
...), starting more than a handful is waste. If you want to start getty
s on all 64, feel free.
The pty
(and some other exotic starting letters) are pseudo tty
s, faked by software to run e.g. xterm
s and other tty
users, in contrast to the "real" tty
s (which aren't so real anymore...).
Normally they are unused .
All tty13
–tty63
, when not specially activated, cost only 3 × 51 special files in /dev/
(one tty
, one vcs
, and one vcsa
for each console), and 51 NULL pointers in the kernel memory. When a console is unused, kernel doesn’t allocate any data for it (besides aforementioned pointer in vc_cons[]
).
Ask Linus Torvalds why he choose #define MAX_NR_CONSOLES 63
(and not 31
, for example) in tty.h
.
Computers or other devices running Linux can have any number (including 0) of keyboards or input device of any shape and layout connected to them which can have any number of function keys.
The kernel in its default configuration allows up to 63 virtual consoles to be allocated and provides an API to map input events to switching consoles, and also to allocate/deallocate/switch console programmatically (see the ioctl_console(2)
man page).
The loadkeys
utility can be used to load that mapping, dumpkeys
to dump it.
For instance, here with a typical British basic USB PC keyboard (with F1 .. F12 keys) connected to a PC running Ubuntu 18.04, dumpkeys
indicates that consoles 1 to 12 can be switched to with Alt-F1 to Alt-F12, consoles 13 to 24 with AltGr-F1 to AltGr-F12, consoles 25 to 36 with Alt+Shift+F1 to Alt+Shift+F12, and I can use Alt+Left and Alt+Right to cycle through consoles (which allows me to access consoles above 36).
And I can allocate more consoles with openvt
(though it's enough to open the tty device to allocate it) or switch between them with chvt
.
12<N<64
instead of7<N<64
? Are 7<N<13` any different from12<N<64
, or you already know what 7<N<13` are used for?