Strovent SystemsSign in
Reference

TERM and terminfo

How a host learns what your terminal can do, and what to do when it says the terminal type is unknown.

Programs on a Unix host do not know your terminal by magic. They read the TERM environment variable, look it up in the terminfo database, and use the sequences listed there.

How TERM is set

  • Over SSH the client sends the terminal type with the "pty" request. It becomes TERM in your shell.
  • Over Telnet the host asks for it with the Terminal Type option (RFC 1091) and the client answers.
  • You can change it for one program: TERM=vt100 less file.

"Unknown terminal type"

Messages such as "unknown terminal type" or "terminal type not found" mean the host has no terminfo entry for that name.

  1. Try a common name that nearly every host has: xterm, vt100 or linux.
  2. On a host you manage, install the terminfo package (for example ncurses-term), which adds xterm-256color and others.
  3. Or copy your terminal's entry into your home folder: infocmp -x xterm-256color | ssh host tic -x -.

Check what the host sees

echo $TERM          your terminal type
tput colors         how many colors it can use
tput cols; tput lines     the window size
infocmp             show the terminfo entry

Window size

The terminal tells the host its size: SSH sends it with the pty request and again on every change ("window change"), and Telnet uses the NAWS option (RFC 1073). If a program draws too wide or too narrow, the host has the old size. Resize the window or type resize or stty size to check. For the fixes, see Terminal size wrong after resize: stty size, resize and COLUMNS.

Character set

Today most hosts use UTF-8. If accents and symbols look wrong:

  • Check the host: locale should show UTF-8 in LANG or LC_ALL.
  • Check the client's character set setting.
  • A host with a plain C or POSIX locale can print ? for non-ASCII characters.

Spotted a mistake? Email [email protected].