The environment variable TERM should normally contain the type name of the terminal, console or display-device type you are using. This information is critical for all screen-oriented programs, including your editor and mailer.
A default TERM value will be set on a per-line basis by either /etc/inittab (Linux and System-V-like UNIXes) or /etc/ttys (BSD UNIXes). This will nearly always suffice for workstation and microcomputer consoles.
If you use a dialup line, the type of device attached to it may vary. Older UNIX systems pre-set a very dumb terminal type like dumb or dialup on dialup lines. Newer ones may pre-set vt100, reflecting the prevalence of DEC VT100-compatible terminals and personal-computer emulators.
Modern telnets pass your TERM environment variable from the local side to the remote one. There can be problems if the remote terminfo or termcap entry for your type is not compatible with yours, but this situation is rare and can almost always be avoided by explicitly exporting vt100 (assuming you are in fact using a VT100-superset console, terminal, or terminal emulator.)
In any case, you are free to override the system TERM setting to your taste in your shell profile. The tset(1) utility may be of assistance; you can give it a set of rules for deducing or requesting a terminal type based on the tty device and baud rate.
Setting your own TERM value may also be useful if you have created a custom entry incorporating options (such as visual bell or reverse-video) which you wish to override the system default type for your line.
Terminal type descriptions are stored as files of capability data underneath /usr/share/misc/terminfo. To browse a list of all terminal names recognized by the system, do
toe | more
from your shell. These capability files are in a binary format optimized for retrieval speed (unlike the old text-based termcap format they replace); to examine an entry, you must use the infocmp(1) command. Invoke it as follows:
where entry-name is the name of the type you wish to examine (and the name of its capability file the subdirectory of /usr/share/misc/terminfo named for its first letter). This command dumps a capability file in the text format described by terminfo(5).
The first line of a terminfo(5) description gives the names by which terminfo knows a terminal, separated by | (pipe-bar) characters with the last name field terminated by a comma. The first name field is the types primary name, and is the one to use when setting TERM. The last name field (if distinct from the first) is actually a description of the terminal type (it may contain blanks; the others must be single words). Name fields between the first and last (if present) are aliases for the terminal, usually historical names retained for compatibility.
There are some conventions for how to choose terminal primary names that help keep them informative and unique. Here is a step-by-step guide to naming terminals that also explains how to parse them:
First, choose a root name. The root will consist of a lower-case letter followed by up to seven lower-case letters or digits. You need to avoid using punctuation characters in root names, because they are used and interpreted as filenames and shell meta-characters (such as !, $, *, ? etc.) embedded in them may cause odd and unhelpful behavior. The slash (/), or any other character that may be interpreted by anyones file system (\, $, [, ]), is especially dangerous (terminfo is platform-independent, and choosing names with special characters could someday make life difficult for users of a future port). The dot (.) character is relatively safe as long as there is at most one per root name; some historical terminfo names use it.
The root name for a terminal or workstation console type should almost always begin with a vendor prefix (such as hp for Hewlett-Packard, wy for Wyse, or att for AT&T terminals), or a common name of the terminal line (vt for the VT series of terminals from DEC, or sun for Sun Microsystems workstation consoles, or regent for the ADDS Regent series. You can list the terminfo tree to see what prefixes are already in common use. The root name prefix should be followed when appropriate by a model number; thus vt100, hp2621, wy50.
The root name for a PC-Unix console type should be the OS name, i.e. linux, bsdos, freebsd, netbsd. It should not be console or any other generic that might cause confusion in a multi-platform environment! If a model number follows, it should indicate either the OS release level or the console driver release level.
The root name for a terminal emulator (assuming it doesnt fit one of the standard ANSI or vt100 types) should be the program name or a readily recognizable abbreviation of it (i.e. versaterm, ctrm).
Following the root name, you may add any reasonable number of hyphen-separated feature suffixes.