Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
Sorry, I maybe need to check this. It's possible this was an SSH login and not the console. Any pointers would be good. –  Casey Mar 28 '10 at 1:49

2 Answers 2

up vote 8 down vote accepted

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.

      # original getty command in /etc/init/tty1.conf
      exec /sbin/getty -8 38400 tty1
      # new command; sets default TERM on /dev/tty1 to "foobar"
      exec /sbin/getty -8 38400 tty1 foobar

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.

  • TERM is inherited by the program that started SSH:
    • SSH from a linux virtual terminal results in a remote TERM of linux;
    • SSH from a commandline in an X-windows terminal emulator results in a remote TERM of whatever TERM was set to prior to the SSH command;
    • SSH from a Windows system using PuTTY defaults to xterm, but this can be changed in PuTTY's configuration;
    • and any of the above settings can be overridden by the shell startup files of the remote user.
share|improve this answer

A lot of good info here:

man 7 term

A default TERM value will be set on a per-line basis by either /etc/inittab (Linux and System-V-like UNIXes) or /etc/ttys (BSD UNIXes). This will nearly always suffice for workstation and microcomputer consoles.

The next problem is that Ubuntu 9.10 does not have /etc/inittab or /etc/ttys.

man inittab

The Upstart init(8) daemon does not use this file, and instead reads its configuration from files in /etc/init. See init(5) for more details.

Looking into /etc/init, you can find the tty*.conf files. They are run by exec'ing getty. So then:

man getty

term The value to be used for the TERM environment variable. This overrides whatever init(8) may have set, and is inherited by login and the shell.

This is good info. Now we know that the default TERM value comes from init(8)

... after all this I didn't manage to figure out how to change the default TERM value used by init.

share|improve this answer
that manpage quote describes setting TERM when logged in on "the console"; Ubuntu uses upstart instead of the older init, and defines tty1 etc in files like /etc/init/tty1.conf –  quack quixote Mar 28 '10 at 2:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.