2

To enable a serial console on Linux, one uses getty (most usually, its variant agetty). This binary takes as argument, among other, the value to initialize the TERM variable with.

On Debian, with Sys V init, the default was vt100. With systemd, the default used to be vt102, and nowadays it's vt220.

After playing a bit with QEMU virtual machines and virt-viewer, as well as virsh console command, I noticed some things:

  • With vt100, ls --color displays colors, but vim's syntax highlighting doesn't work
  • with vt102 or vt220, neither of them displays colors
  • Only with TERM variable set to linux, do both ls and vim use colors

So I guess that independently of the actual "color support", each application looks at the TERM variable and acts accordingly, which would explain the differences noted above.

After reading the Serial Console HOWTO, I understand that the value of the TERM variable should depend on the actual model of physical terminal which would be connected to the serial port, according to its capabilities.

Note that, according to Lennart Poettering's blog, TERM should be set to linux only with real virtual terminals (as opposed to serial ones). On the other hand, Arch Linux' Wiki doesn't seem to mind (see the /etc/inittab lines it proposes).

So my questions are:

In a general case, what happens if the TERM variable is set to linux on a console connected to a less-capable terminal, like a DEC VT100, VT102 or VT220, or some RS-232 software terminal emulators like minicom or termite ?

More realistically (in my particular case), is it OK to set the TERM variable to linux in a "virtual" serial console on a QEMU VM, to which I will connect through virt-viewer or virsh console ?

  • "real virtual" is a somewhat odd turn of phrase, and it is arguable that a DEC VT is "less capable" than the Linux built-in terminal emulator. (-: – JdeBP Jan 4 at 15:51
2

The TERM setting tells the application program what capabilities the terminal it is communicating with has, and how to utilize these capabilities (typically via a library like ncurses). In plain English: it tells what control sequences (escape sequences) it should send to move the cursor arount the screen, to change the text color, how to erase a region of the screen, what sequences the function keys transmit, etc. Some of these capabilities may be missing, like color support.

Most of the terminal types in use today are somehow related to the "grand daddy" of "glass ttys", the DEC VT100. This is why terminal types are mostly interchangeable, so setting the wrong type typcally results in a mostly working setup, but with some glitches.

So, to answer the questions "which should I use" and "what happens if I use the wrong setting"? Some control sequences may be mismatched, i.e. the program sends cursor movement sequences that differ from the ones the terminal emulator expects. Or color support is missing. (Btw. the original VT100 did definitely not support color...) The correct setting should be provided by the terminal emulator documentation, but there is no harm in experimenting to see which setting works the best. It's OK to use "linux" if it works for you.

  • The Linux built-in terminal emulator famously swaps the DECFNK sequences for Home and End with those for Find and Select, for example. – JdeBP Jan 4 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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