How is the default TERM shell variable value set?

After upgrading to Maverick I have my TERM variable set to 'dumb', this does not happen with the same home dir running from Lucid and I didn't manually changed anything related to TERM.

Any idea where is the TERM variable expected to be set from?


To elaborate on what Gilles says, suppose you are remote connecting to your ubuntu from Windows using Putty.

In the putty config options, under Connection->Data there is a setting called terminal-type string. You can set your TERM there and putty instructs SSH to set that environment variable. At some point after that your shell is going to be executed, probably /bin/bash and it gets its environment from its parent process, probably the sshd process.

The same holds true if you ssh from a remote linux box, its just that the local TERM environment variable is passed through via ssh to the remote connection.

In the case of a terminal emulator it is the job of the terminal emulator to set the TERM environment variable. e.g. getty sets TERM to "linux" and forks a shell process (/bin/bash). or gnome-terminal sets TERM to "xterm" and forks a shell process.


To answer your question literally, the terminal emulator is supposed to set $TERM

To solve your problem would require at least knowing what terminal emulator you use. It could be a bug or misconfiguration in the terminal emulator or a problem with your shell startup files (probably ~/.bashrc, but possibly ~/.bash_profile, /etc/bashrc, /etc/profile, ...).

¹ Assuming you're not using a hardware terminal; then it would be the argument to getty, called from inittab (older releases using SysVinit) or /etc/init/tty*.conf (Ubuntu ≥9.10, using Upstart).


If you want to change the terminal make sure you check out the update-alternatives functionality.

For instance:

update-alternatives --config x-terminal-emulator

Many of the various system default options in Ubuntu are set via this method. Another common one would be a www-browser

update-alternatives --config x-www-browser