The $TERM shell value in Ubuntu defaults to "xterm" for a console login. How can I change it so it defaults to "xterm-color"? I'm asking because it looks like this is the easiest way to turn-on the color prompt.
I am aware you can reset the TERM value in the .bashrc or other login script, but I'd rather just force the TERM value to a more reasonable default.
Best Answer
The TERM variable stores the name of an entry in the terminfo database that helps the OS determine how to display information to your terminal. What it defaults to depends entirely on how you've logged in.
Usually, "the console" means you're physically at the computer, logging into one of the text-based virtual terminals (VT1-6).
TERM defaults to linux (this may differ between distributions; vt100 is a safe alternative)
To change this, on Ubuntu 9.10, you'll need to tweak the getty command defined in /etc/init/tty1.conf. That will change the setting for /dev/tty1 (VT1), and you'll need to make the same changes in /etc/init/tty2.conf, ..tty3.conf, etc to get the other virtual terminals as well.
If you're logged into X/Gnome/KDE (VT7, 8, or 9), you're not using a console, at least in this context. Technically this is logging into X and using a pseudo-terminal via a terminal emulator application -- that's what gives you the window that shows your shell & commandline.
TERM is initially set by your terminal emulator. It can be modified in your shell startup files (~/.bashrc, ~/.profile, etc).
xterm, rxvt, xterm-color, xterm-256color are all common values
To change this value, consult the documentation for your terminal emulator. For example, if using rxvt-unicode (aka urxvt), you'd use the
-tn termname
commandline option.If you're logged in remotely (via SSH or remote X), you're definitely not using a console in any context; again, you're using a pseudo-terminal.