After reading some messages posted during the last few days in a NetBSD mailing list, I realized that several people do not know what is the real purpose of the TERM environment variable.

The misinterpretation is the following: they think that TERM is used to specify the terminal type that should be emulated on your terminal. Thus, e.g., if you explicitly set TERM=linux in a NetBSD console, everything should work as in a Linux system. This is far from reality, as things work quite the other way around.

TERM is used to tell the termcap (or terminfo) library which terminal type you are really using. This way, the library, which acts as an abstraction layer for terminal control codes, can generate the correct control sequences to manage the screen. For example, if you remotely log in into any Unix server from a Linux box, TERM should be set to linux (which usually happens automatically) so that the remote applications can be displayed correctly.

Anyway, I'm not going to describe the details in this little post. If you want to learn more, read the TTYs and X Window: Unix Now and Then article by Hubert Feyrer.