Specifying Terminal Characteristics

Unix programs are generally written to beterminal-independent: they don’t know about or rely on the specific characteristics of any particular kind ofterminal, but rather, they call a standard screen manipulation library that is responsible for interfacing to actual terminals. Such libraries serve to map general terminal characteristics and functions (e.g., clearing the screen) to the specific character sequences required to perform them on any specific terminal.

Terminal definitions are stored in databases on the system, and users indicate what kind of terminal they are using by setting the TERM environment variable (usually at login time). These databases are handled differently under BSD and System V and are the subject of the next section.

termcap and terminfo

Programs use the name specified in the TERM environment variable as a key into the system terminal definitions database. Under the BSD scheme, terminal definitions are stored in the file /etc/termcap ; under System V, they are stored in the subdirectories of the terminfo top-level subdirectory. Some systems provide both facilities:

AIX
/usr/lib/terminfo
FreeBSD
/etc/termcap (a link to /usr/share/misc/termcap)
Linux
/etc/termcap and /usr/share/terminfo
HP-UX
/usr/lib/terminfo (a link to /usr/share/lib/terminfo)
Solaris
/etc/termcap and /usr/share/lib/terminfo
Tru64
/usr/share/lib/termcap and /usr/lib/terminfo

This section provides a brief overview of termcap and terminfo entries. See the Nutshell ...

Get Essential System Administration, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.