3

Linux has 7 virtual consoles, which correspond to 7 device files /dev/tty[n].

Is a virtual console running as a process, just like a terminal emulator? (I am not sure. It seems a virtual console is part of the kernel, and if that is correct, it can't be a process.)

Is a virtual console implemented based on pseudoterminal, just like a terminal emulator? (I guess no. Otherwise, a virtual console's device file will be /dev/pts/[n], instead of /dev/tty[n])

Thanks.

  • 2
    Does this site endorse these systematic downvotes and close votes? AFAIK, there has never been anything taken against them all these years. – Tim Nov 28 '18 at 1:48
  • No, they're not ptys. But where did you get the idea that there's only 7 of them? ls /dev/tty[0-9]* | wc -l returns 64 on my system. – mosvy Nov 28 '18 at 7:30
7

That is incorrect.

There's a terminal emulator program built into the Linux kernel. It doesn't manifest as a running process with open file handles. Nor does it require pseudo-terminal devices. It's layered on top of the framebuffer and the input event subsystem, which it uses internal kernel interfaces to access. It presents itself to application-mode systems as a series of 63 (not 7) kernel virtual terminal devices, /dev/tty1 to /dev/tty63.

User-space virtual terminals are implemented using pseudo-terminal devices. Pseudo-terminal devices, kernel virtual terminal devices, and real terminal devices layered on top of serial ports are the three types of terminal device (as far as applications programs are concerned) in Linux.

Because of a lack of coördination, Linux documentation is now quite bad on this subject. There has been for several years no manual page for kernel virtual terminal devices on several Linux operating systems, although there are pages for the other two types of terminal device. This manual page would have explained the correct number or devices and their device file names and used to read:

A Linux system has up to 63 virtual consoles (character devices with major number 4 and minor number 1 to 63), usually called /dev/ttyn with 1 <= n <= 63. The current console is also addressed by /dev/console or /dev/tty0, the character device with major number 4 and minor number 0.

Debian people noticed that Debian was missing a console(4) manual page in 2014, and switched to installing the one from the Linux Manpages Project, only for people in that same project to delete their console(4) manual page a year and a bit later in 2016 because "Debian and derivatives don't install this page" and "Debian no longer carries it".

Further reading

  • Thanks. (1) "The current console is also addressed by /dev/console or /dev/tty0". If I am correct, /dev/tty is the device file of the controlling terminal of the current process session. Are /dev/console, /dev/tty0 and /dev/tty different? (2) Yes, there are /dev/ttyn with 1 <= n <= 63. When some says there are 7 virtual consoles in Linux, in what sense do they mean? Do they mean there are only 7 accessible by key shortcuts? – Tim Nov 28 '18 at 12:06
  • Well … you said it, and only you to my knowledge. When you said it, in what sense did you mean? (-: – JdeBP Nov 28 '18 at 12:54
  • I can switch to virtual console #2, by Ctrl-Alt-F2. May I ask how I can switch to virtual console #20? – Tim Nov 28 '18 at 12:57
  • You don't need my permission to ask a question. (-: But you'll probably see it speedily closed as a duplicate of unix.stackexchange.com/questions/333895 , unix.stackexchange.com/questions/82368 , and their ilk. – JdeBP Nov 28 '18 at 13:03
  • You can be assured that I am just acting polite by saying in that way. (: – Tim Nov 28 '18 at 13:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.