16

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
1
  • 5
    You are in fact not creating Linux VTs by pressing CTRL-ALT-F1 (and so on), they are already there, you just don't see them as your display manager was invoked automatically on startup, and then you ended up in X (which is, confusingly, run on tty 7). Check out /etc/inittab and you'll see how this works. Jan 3, 2013 at 8:28

2 Answers 2

13

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).

-2

It's not a linux specific thing, and ttys are not only used for virtual terminals. They're also used e.g. when you start an xterm once you're in a graphic interface. If there were fewer tty devices, you would not be able to have many xterms or ssh logins.

6
  • Hm, care to explain this a bit more? When you run xterm under X, don't you get a pts, and not a tty? Jan 3, 2013 at 8:18
  • 1
    Have a look at unix.stackexchange.com/questions/4126/…
    – Jenny D
    Jan 3, 2013 at 8:48
  • OK, I've read it, but it is still not clear. Are you saying, when I start xterm, that process is somehow associated with a tty device file in /dev, so, if there were fewer of them, you could actually "run out" of ttys? Jan 3, 2013 at 12:58
  • 4
    Actually the device interface for X emulators is not a tty -- it's a "pseudo terminal" (pt). Those are managed dynamically by the kernel, but currently existing ones are listed in /dev/pts/. The tty command will give you your current device -- try in X then try it in a VT.
    – goldilocks
    Jan 3, 2013 at 16:03
  • 2
    You're confusing /dev/ttyN (virtual consoles, sometimes called virtual terminals) with the old /dev/ptyN (pseudo-terminals, also sometimes called virtual terminals). Linux now uses dynamically-allocated /dev/pts/N instead of the old statically-allocated /dev/ptyN. Jan 4, 2013 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .