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
TERMin 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.
- Try a common name that nearly every host has:
xterm,vt100orlinux. - On a host you manage, install the terminfo package (for example
ncurses-term), which addsxterm-256colorand others. - 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:
localeshould showUTF-8inLANGorLC_ALL. - Check the client's character set setting.
- A host with a plain
CorPOSIXlocale can print?for non-ASCII characters.
Related
- VT, xterm and terminal types
- Colors
- Telnet basics
- Unknown terminal type or "Error opening terminal" when you use tmux, screen or SSH
- Terminal size wrong after resize: stty size, resize and COLUMNS
- TERM xterm, xterm-color or xterm-256color: which to use
- tput "No value for $TERM and no -T specified" and "TERM environment variable not set"