Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search
Next Previous Contents

10. Terminal Emulation (including the Console)

10.1 Intro to Terminal Emulation

A trivial type of terminal emulation is where you set up a real terminal to emulate another brand/model of terminal. To do this you select the emulation you want (called "personality" in Wyse jargon) from the terminal's set-up menu. This section will not discuss this case.

Since a PC has a screen and keyboard (as does a real terminal) but also has much more computing power, it's easy to use some of this computing power to make the PC computer behave like a real text terminal. Still a third type is where you just use a text-based interface (at the console --usually just the monitor) to your Linux PC, either by a terminal screen (such as xterm) in Xwindow or by a "virtual terminal".

To fully emulate a real terminal on a PC requires that a serial port of the computer will be used to connect the emulated terminal to another computer. This would be either with a direct cable connection from serial port to serial port, or via a modem. But in other cases, the serial port will not be used directly as the interface. Instead, the interface may be a network and the flow of bytes to and from the terminal will travel in network packets via either a modem on a serial port or via an ethernet port.

Emulation for connection to a remote computer provides more that just a real text-terminal since the PC doing the emulation can also do other tasks at the same time it's emulating a terminal. For example, for serial port connections, kermit or zmodem may be run on the PC to enable transfer of files over the serial line (and possibly over the phone line via a modem) to the other computer that you are connected to. The emulation needs only to be run on one of the virtual consoles of the PC, leaving the other virtual consoles available for using the PC in command-line-interface.

For Linux see Make a Linux PC a serial port terminal. Emulation software for this also available for use under MS Windows. See Make a non-Linux PC a terminal This can be used to connect a Windows PC (as a Text-Terminal) to a Linux PC.

Most Linux free software can only emulate a VT100, VT102, or VT100/ANSI, xterm, or Wyse60 (but not fully). Since most PC's have color monitors while VT100 and VT102 were designed for a monochrome monitor, the emulation usually adds color capabilities (including a choice of colors). Sometimes the emulation is not 100% perfect but this usually causes few problems. None of them provide programmable function keys. The non-free emulation software running under MS Windows can emulate many more terminals than free Linux can.

10.2 Don't Try to Use TERM Variable for Emulation

Some have erroneously thought that they could create an emulator at a Linux console (monitor) by setting the environment variable TERM to the type of terminal they would like to emulate. This does not work. The value of TERM only tells an application program what terminal you are using. This way it doesn't need to interactively ask you this question. If you're at a Linux PC monitor (command line interface) it's a terminal of type "Linux" and since you can't change this TERM must be set to "Linux". This should happen without you needing to do anything.

If you set it to something else you are fibbing to an application program. As a result, it will incorrectly interpret certain escape sequences from the console resulting in a corrupted interface. Since the Linux console behaves almost like a vt100 terminal, it could still work almost OK if you falsely claimed it was a vt100 (or some other terminal which is close to a vt100). In this case it may seeming work OK most of the time but once in a while will make a mistake.

10.3 Serial Communication programs (mostly dialing)

while the newer free PuTTY program can connect directly to a serial line but can't dial, most of of the older programs did dialing out via a serial port modem. Some dialing programs are for making a PPP connection to the Internet via a modem, such as wvdial, and don't normally include any terminal emulation. But some other programs (such as minicom or seyon) do both terminal emulation and modem dialing (without PPP so it's not easy to use them to connect to the internet). But since these programs connect to a modem via a specified serial port (including "internal" serial ports that have no connector on the back of the PC), they may be used to connect to a serial line via a possible serial port connector on the back of a PC. For this case you just set them up to connect without dialing a phone number. The program "picocom" just does terminal emulation although it's possible to type in a modem command and a phone number to dial out manually. These programs are also useful for testing modems. Seyon is only for use with X Window and can emulate Tektronix 4014 terminals. In the past one could use dialing programs to dial up some public libraries to use their catalogs and indexes, or even read magazine articles on line before the Internet was widely available. But today such activity is almost always done using the Internet.

The communication program C-Kermit (sometimes just called kermit) doesn't do terminal emulation for Linux (in 2006). But Kermit can emulate many terminals in its non-free MS Windows versions so you`ll see lots of claims that Kermit can do terminal emulation. With Linux, it's merely a semi-transparent pipe between whatever terminal you are on and the remote site you are connected to. Thus if you use kermit on a Linux PC the terminal type will be "Linux". If you have a Wyse60 connected to your PC and run kermit from that, you will appear as a Wyse60 to the remote computer (which may not be able to handle Wyse60 terminals). Minicom emulates a VT102 and if you use it on Wyse60 terminal vt102 the remote host will think you are a vt102 and send you vt102 escape sequences. These will flow into your computer's serial port and will get translated to the Wyse escape sequences before going out another serial port on your computer to your Wyse60 terminal. C-Kermit can't do this sort of thing.

Emulators exist under DOS such as telix and procomm work just as well. The terminal emulated is often the old VT100, VT102, or ANSI (like VT100).

Emulation under X Window

There are many terminal emulation programs (such as xterm, uxterm. gnome-terminal, and konsole) which may be run under X Window. They can usually emulate a VT102, but some may be able to emulate at VT220, or Tektronix 4014. They provide a command line interface to the computer but they don't communicate via the serial port like a text terminal. See Ubuntu -- x-terminal-emulator for a brief list of such emulators. Some are multilingual. Your Linux distribution has likely installed one for you.

Real terminals may be better

Unless you are using X Window with a large display, a real terminal was often nicer to use than emulating one. It often had better resolution for text (since it's monochrome), and had no disk drives to make annoying noises.

10.4 Testing Terminal Emulation

For the VT series terminals there is a test program: vttest to help determine if a terminal behaves correctly like a vt53, vt100, vt102, vt220, vt320, vt420 etc. There is no documentation but it has menus and is easy to use. To compile it run the configure script and then type "make". It may be downloaded from: http://www.ibiblio.org/pub/Linux/utils/console/

10.5 The Linux Console

The console for a PC Linux system is normally the computer monitor in text mode. It emulates a terminal of type "Linux" and the escape sequences it uses are in the man page: console_codes. There is no way to make this interface emulate anything else. But of course you can run emulation software on your PC so that the monitor and keyboard will emulate a text terminal while that software program is running. Setting the TERM environment variable to any type of terminal other than "Linux" will not result in emulating that other terminal. It will only result in a corrupted interface since you have falsely declared (via the TERM variable) that your "terminal" is of a type different from what it actually is: Linux. See Don't Use TERM For Emulation

In X Window, using a terminal emulator gives you the equivalent of a console. For KDE they chose to call this emulation "konsole". In some cases, the console for a Linux PC is a text-terminal. One may recompile Linux to make a terminal receive most of the messages which normally go to the console. See Make a Serial Terminal the Console.

The "Linux" emulation of the monitor is flexible and has features which go well beyond those of the vt102 terminal which it was intended to emulate. These include the ability to use custom fonts and easily re-map the keyboard. These extra features reside in the console driver software (including the keyboard driver). The console driver only works for the monitor and will not work for a real terminal even if it's being used for the console. Thus the "console driver" is really a "monitor driver". In the early days of Linux one couldn't use a real terminal as the console so "monitor" and "console" were once always the same thing.

The stty commands work for the monitor-console just like it was a real terminal. They are handled by the same terminal driver that is used for real terminals. Bytes headed for the screen first go thru the terminal (tty) driver and then thru the console driver. For the monitor some of the stty commands don't do anything (such as setting the baud rate). You may set the monitor baud rate to any allowed value (such as a slow 300 speed) but the actual speed of putting text on the monitor screen will not actually change. The file /etc/ioctl.save stores stty settings for use only when the console is in single user mode (but you are normally in multiuser-user mode). This is explained (a little) in the init man page.

Many commands exist to utilize the added features provided by the console-monitor driver. Real terminals, which use neither scan codes nor VGA cards, unfortunately can't use these features. To find out more about the console see the Keyboard-and-Console-HOWTO. Also see the various man pages about the console (type "man -k console"). Unfortunately, much of this documentation is outdated.

10.6 Emulation Software

Since there are free programs to emulate the most common terminals, you will unlikely need to use any non-free software. But if you need to purchase software you should try to throughly check out what other customers have to say about it.

Make a Linux PC a serial port terminal

Unless you want to emulate the standard vt100 (or close to it), xterm, or a Wyse 60, there doesn't seem to be much free terminal emulation software available for Linux. The free programs are minicom, picocom, and for GUI: seyon and PuTTY. Both seyon and PuTTY can emulate either xterm or vt100 (or close to it). PuTTY is much newer but its main use is an SSH client. Seyon is much older but with more features (some of which are seldom needed). There are also more recent (but weaker) "emulators" for a GUI interface: gtkterm and cutecom, neither of which can emulate any terminal except of type "dumb" ??). Seyon can also emulate a Tektronix 4014 terminal. For Wyse see Wyse 60 emulator.

Both gtkterm (and likely cutecom) don't use escape sequences, and might be said to emulate a terminal of type "dumb" so they would be quite slow if used as a text terminal for editing files on the host computer using the vim editor, etc. gtkterm is simple to set up and very weak in capabilities but it does show its current status at the bottom of the screen.

Minicom, PuTTY, picocom, gtkterm, or cutecom may be used to emulate a directly connected terminal by simply starting one of them. For minicom, you must configure it for the serial port used). Picocom is like a mini-minicom and doesn't have automatic dialout capability. Gtkterm might be called a "mini-mini-minicom".

Minicom : For the case of minicom you obviously don't try to dial-out. When you want to quit minicom (after you logout from the other PC) you use minicom's q command to quit without reset since there is no modem to reset. When minicom starts, it automatically sends out a modem init string to the serial port. But since there's no modem there, the string gets put after the "login:" prompt. If this string is mostly capital letters, the getty program (which runs login) at the other PC may think that your terminal has only capital letters and try to use only capital letters. To avoid this, configure the modem init strings sent by minicom to null (erase the init strings).

The non-free terminal emulator "Procomm" (which is from the MS world), can be used on a Linux PC if you run dosemu to emulate Dos or possibly in a mode emulating MS Windows. The last version of it seems to be 4.8 released in around 2000 so it will likely not work with modern MS systems. It was sold by Symantec which has many files supporting it which may be found using their search engine at http://www.symantec.com/. And if you check the Internet (in 2008), it's still being sold here and there.

There's a specialized Linux distribution: Serial Terminal Linux. It will turn a PC to into a minicom-like terminal. It's small (fits on a floppy) and will not let you use the PC for any other purpose (when it's running). See http://www.eskimo.com/~johnnyb/computers/stl/. It will let you have more than one session running (similar to virtual terminals), one for each serial port you have.

TERM (non-free commercial software from Century Software) Terminal Emulator can emulate Wyse60, 50; VT 220, 102, 100, 52: TV950, 925, 912; PCTERM; ANSI; IBM3101; ADM-1l; WANG 2110. Block mode is available for IBM and Wyse. It runs on a Linux PC.

Make a Linux PC an IBM network terminal

This happens automatically when you run programs like telnet or ssh, provided of course that your computer is connected to a network (perhaps via a modem). Telnet normally uses a network (often the Internet) to connect your console, which emulates a terminal of type "Linux", to a remote computer for you to log in to. However, there are some free programs that allow you to use telnet with IBM terminal emulation on your PC to connect with IBM mainframes.

One IBM program emulates an IBM tn5250 terminal and printer and another emulates an IBM c3270. There's also one that emulates an IBM pr3287 printer (the mainframe thinks it's connected to the printer). The Debian distribution has these. It's reported that the tn5250 emulates a vt keyboard under Linux and not a 5250 keyboard like it should. Also, it's reported that the documentation and keyboard mapping for the MS Windows version are better than for the Linux version.

Make a non-Linux PC a terminal

Emulators exist which run on non-Linux PCs. They permit you to use a non-Linux-PC as a terminal to connected to a Linux-PC. Under DOS there were many programs that not only emulated a terminal but let you dial out with a modem so that you could connect to other computers over telephone lines (without getting connected to the Internet). Of historical interest is DOS Serial Communications (1994).

Today Windows comes with "HyperTerminal" (formerly simply called "Terminal" in Windows 3.x and DOS). Competing with this is both the free (open source) PuTTY and the non-free "HyperTerminal Private Edition" http://www.hilgraeve.com/htpe/index.html which is non-free to business. It can emulate vt-220. PuTTY emulates xterm and supposedly also vt-102 but it doesn't have file transfer capabilities (such as zmodem) like HyperTerminal does. But PuTTY permits a display with a height of over 24 lines (set the Linux shell variable LINES to say 32 by typing: LINES=32). Turbosoft's TTWin (non-free) can emulate over 80 different terminals under Windows. See http://www.ttwin.com/ or http://www.turbosoft.com.au/ (Australia). See also WRQ

For using a Mac computer to emulate a common terminal use either PuTTY, Linux's "minicom" (ported to the Mac OS X) or the old "zterm" (shareware). For very old Macs prior to OS X, see the mini-howto: Mac-Terminal. Carnation Software has non-free software to emulate a wide variety of terminals on a Mac. Mac OS X has a "terminal" program that gives you a terminal window just like the xterm window in Linux's X Window. In that window you may run "minicom" (if it's available). Both the "fink" and "darwinports" projects have ported minicom to the Mac, but they may not have the most recent version and you might need to compile minicom yourself.

One place to check terminal emulation products is Shuford's site, but it seems to lists old products (which may still work OK). The fact that most only run under DOS (and not Windows) indicates that this info is dated. See http://www.cs.utk.edu/~shuford/terminal/term_emulator_products.txt.

10.7 Colors on Emulated Terminals

Since displays used for text terminal emulation are almost always color displays, you can utilize color coding of words. Besides displaying directories this way (See Example for ls Function) some other Linux programs display color-coded text. It seems to mostly happen without any configuring but there may be color conflicts. For example, if you have set the background color green, then if a programs sends you green text, it will be difficult or impossible to read.

Color usually works by programs sending ANSI escape sequences to the terminal. One might think that an emulated terminal would show the ANSI escape codes in the terminfo. for the terminal. But this is not usually the case since if a terminal support colors it seems to be assumed that these color will be sent to the terminal using the ANSI encoding.

If you want to see what these encodings are, look at "man console_codes". The ECMA-48 color codes in this man page appear to be a subset of the ANSI color codes. For excruciating details see ANSI escape code - Wikipedia. Note that these ANSI codes cover more than just colors.

For PuTTY one can select the precise color to display for every ANSI code by using the settings menu and clicking on "Colours". For example if you have your screen background light green, then you can remap that ANSI color to some shade of brown that you select. Note that light green is called "Green Bold". It's bold because it contains a lot of white which makes it a light color.


Next Previous Contents