Linux TTY – Why Are There So Many Virtual Terminal Devices?

consoledeviceslinuxtty

I've been reading the Advanced Linux Programming book and it mentions about virtual terminals which, if I understood it correctly, it is a Linux-specific feature (not in Unix) to allow multiple login consoles in a non X11 system. You create virtual terminals by pressing ALT-F2. I'm running Linux Mint and in my /dev folder though I see many tty devices and I don't know what they are for. Here is the grepped output:

crw-rw-rw-  1 root tty       5,   0 Jan  2 19:45 tty
crw--w----  1 root tty       4,   0 Jan  2 19:10 tty0
crw-rw----  1 root tty       4,   1 Jan  2 19:10 tty1
crw--w----  1 root tty       4,  10 Jan  2 19:10 tty10
crw--w----  1 root tty       4,  11 Jan  2 19:10 tty11
crw--w----  1 root tty       4,  12 Jan  2 19:10 tty12
crw--w----  1 root tty       4,  13 Jan  2 19:10 tty13
crw--w----  1 root tty       4,  14 Jan  2 19:10 tty14
crw--w----  1 root tty       4,  15 Jan  2 19:10 tty15
crw--w----  1 root tty       4,  16 Jan  2 19:10 tty16
crw--w----  1 root tty       4,  17 Jan  2 19:10 tty17
crw--w----  1 root tty       4,  18 Jan  2 19:10 tty18
crw--w----  1 root tty       4,  19 Jan  2 19:10 tty19
crw-rw----  1 root tty       4,   2 Jan  2 19:10 tty2
crw--w----  1 root tty       4,  20 Jan  2 19:10 tty20
crw--w----  1 root tty       4,  21 Jan  2 19:10 tty21
crw--w----  1 root tty       4,  22 Jan  2 19:10 tty22
crw--w----  1 root tty       4,  23 Jan  2 19:10 tty23
crw--w----  1 root tty       4,  24 Jan  2 19:10 tty24
crw--w----  1 root tty       4,  25 Jan  2 19:10 tty25
crw--w----  1 root tty       4,  26 Jan  2 19:10 tty26
crw--w----  1 root tty       4,  27 Jan  2 19:10 tty27
crw--w----  1 root tty       4,  28 Jan  2 19:10 tty28
crw--w----  1 root tty       4,  29 Jan  2 19:10 tty29
crw-rw----  1 root tty       4,   3 Jan  2 19:10 tty3
crw--w----  1 root tty       4,  30 Jan  2 19:10 tty30
crw--w----  1 root tty       4,  31 Jan  2 19:10 tty31
crw--w----  1 root tty       4,  32 Jan  2 19:10 tty32
crw--w----  1 root tty       4,  33 Jan  2 19:10 tty33
crw--w----  1 root tty       4,  34 Jan  2 19:10 tty34
crw--w----  1 root tty       4,  35 Jan  2 19:10 tty35
crw--w----  1 root tty       4,  36 Jan  2 19:10 tty36
crw--w----  1 root tty       4,  37 Jan  2 19:10 tty37
crw--w----  1 root tty       4,  38 Jan  2 19:10 tty38
crw--w----  1 root tty       4,  39 Jan  2 19:10 tty39
crw-rw----  1 root tty       4,   4 Jan  2 19:10 tty4
crw--w----  1 root tty       4,  40 Jan  2 19:10 tty40
crw--w----  1 root tty       4,  41 Jan  2 19:10 tty41
crw--w----  1 root tty       4,  42 Jan  2 19:10 tty42
crw--w----  1 root tty       4,  43 Jan  2 19:10 tty43
crw--w----  1 root tty       4,  44 Jan  2 19:10 tty44
crw--w----  1 root tty       4,  45 Jan  2 19:10 tty45
crw--w----  1 root tty       4,  46 Jan  2 19:10 tty46
crw--w----  1 root tty       4,  47 Jan  2 19:10 tty47
crw--w----  1 root tty       4,  48 Jan  2 19:10 tty48
crw--w----  1 root tty       4,  49 Jan  2 19:10 tty49
crw-rw----  1 root tty       4,   5 Jan  2 19:10 tty5
crw--w----  1 root tty       4,  50 Jan  2 19:10 tty50
crw--w----  1 root tty       4,  51 Jan  2 19:10 tty51
crw--w----  1 root tty       4,  52 Jan  2 19:10 tty52
crw--w----  1 root tty       4,  53 Jan  2 19:10 tty53
crw--w----  1 root tty       4,  54 Jan  2 19:10 tty54
crw--w----  1 root tty       4,  55 Jan  2 19:10 tty55
crw--w----  1 root tty       4,  56 Jan  2 19:10 tty56
crw--w----  1 root tty       4,  57 Jan  2 19:10 tty57
crw--w----  1 root tty       4,  58 Jan  2 19:10 tty58
crw--w----  1 root tty       4,  59 Jan  2 19:10 tty59
crw-rw----  1 root tty       4,   6 Jan  2 19:10 tty6
crw--w----  1 root tty       4,  60 Jan  2 19:10 tty60
crw--w----  1 root tty       4,  61 Jan  2 19:10 tty61
crw--w----  1 root tty       4,  62 Jan  2 19:10 tty62
crw--w----  1 root tty       4,  63 Jan  2 19:10 tty63
crw--w----  1 root tty       4,   7 Jan  2 19:10 tty7
crw--w----  1 root tty       4,   8 Jan  2 19:10 tty8
crw--w----  1 root tty       4,   9 Jan  2 19:10 tty9

Best Answer

These are specifically virtual console devices, in Linux terminolgy. Supporting virtual consoles on the same physical device isn't unique to Linux (for example, BSD calls them “hardware terminal ports”).

Linux doesn't have a mechanism for creating console devices on demand. The 63 consoles are not always active (you need to activate ttyN in order to switch to it with (Ctrl+)Alt+FN), but to activate one requires opening the console device (the openvt command does that, as do getty and the X server). So the device entry must exist all the time, or else it has to be created manually before it can be used.

Modern Linux systems (with udev or devtmpfs) create device entries for every device that is present on the system. All the virtual consoles are always present (whether they're active or not), so all entries are created. Most users don't need nearly that many — in fact most users never see anything but the virtual console that X is running on. But there are a few who do, and need to patch their kernel to allow more than 63 consoles, because they run large machines with many hardware consoles).