11

I have ssh access to a remote machine. In this machine if I run echo $TERM I get xterm.

If I want to change my terminal emulator to some other emulator (assuming that it's installed on the remote machine), how would I do it?

2 Answers2

16

The value of the environment variable TERM is used by the server (in system V, or BSD, derived OSes) to control how input is recognized by the system, and what capabilities exist for output. Some terminal types are similar enough that they can be interchanged while still remaining usefull, while others could make the system unusable until you open a new connection with a supported value for TERM. For example, from one Linux system to another, you would probably experience very little difference between vt100, vt220, and xterm settings. Most of the differences would be in how output is displayed, and whether colors or bold fonts are available to that type of terminal. The termcap database lists all the terminal types, with their various capabilities.

As long as you don't switch to a terminal type that your keyboard and screen aren't compatible with, you'll be fine.

read the man page for term, and termcap, on your system for more information.

To change the terminal type:

in bash:

export TERM=vt100

in bourne shell or ksh:

TERM=vt100
export TERM

in csh or tcsh:

setenv TERM vt100

vt100 is a pretty safe terminal to start playing with. it's compatible with xterm, but it doesn't display colors or bold fonts, and may not recognize your F* keys, but you're unlikely to really mess anything up using vt100.

A lot of people use terminal detection in personal init scripts to optimize their user experience depending how how they're logging into the server. For example, set a plain PS1 if you're using vt100, use color and dynamic variables when using bash in an xterm.

Good luck with your research.

Tim Kennedy
  • 19,697
  • 3
    @intrpc Note that it's pretty rare to need to change the TERM variable; it's mostly necessary when you log in to an older system that doesn't know about the name of a newer terminal (and there haven't been many new terminal types in the last 15 years or so, most terminal emulators style themselves as xterm). TERM is what terminal type programs believe they're talking to, it doesn't change what the terminal actually is. – Gilles 'SO- stop being evil' Nov 01 '11 at 22:40
9

You're misunderstanding.

Your console or terminal or PuTTY instance on the LOCAL side is the actual "terminal emulator", even though nowadays we just shorten then to "terminals". The usage stems from back when people actually used monitor-and-keyboard terminals to sign on to a mainframe server rather than using multiple consoles and graphical user environments.

The $TERM variable simply tells the remote system what kind of control codes your terminal will understand when it sends them (for instance, to generate text-based menus or anything based on libncurses).

I'm not sure what exactly you want to accomplish, but changing $TERM probably won't help.

  • Thanks @Shadur, this is helpful. I would like to enable support for more colors. I am having problems with escaping characters, as I explain in the update in this question. In case it matters, both machines/systems are modern (Ubuntu 11.10 on my local machine and Red Hat Enterprise Linux Server release 5.4 (Tikanga) on the remote machine) – Amelio Vazquez-Reina Nov 01 '11 at 15:54
  • Sorry, the link was to the wrong question. I just edited my comment above. – Amelio Vazquez-Reina Nov 01 '11 at 15:56
  • Then your problem still isn't the TERM variable, because my gnome-terminal window, SSHed to a remote server with a $TERM value of xterm has no problems rendering ansi colors. It might be better if you explain your problem rather than asking how to implement what you think should be the solution. – Shadur-don't-feed-the-AI Nov 01 '11 at 15:58
  • Thanks, but I didn't say that "my problem" was the $TERM variable. Also, I am not asking this question for the sole purpose of finding a solution to a different problem/question. If anything, my other question motivated this question. Finally, I don't think there is anything wrong with hoping to learn more about how terminal emulators work by asking this question. – Amelio Vazquez-Reina Nov 01 '11 at 17:50
  • By the way, don't get me wrong, I appreciate your advice and, as I said earlier, your answer helped me understand terminal emulators better. – Amelio Vazquez-Reina Nov 01 '11 at 17:57