I have read a lot of articles and SE questions regarding how and where the default $TERM environmental variable gets set.

Unfortunately in Debian 8.1 I can't seem to find where the default $TERM variable is set when logging in to the system from tty1.

I would love to be pointed in the right direction if this is indeed a duplicate question but the following questions didn't seem like they provided an answer:

tmux, TERM and 256 colours support

Where does the TERM environment variable default get set?

Is it correct to set the $TERM variable manually?


When I log in via tty1 here is what $TERM is set to:

$> echo $TERM

Listing of /usr/lib/systemd/, note that there is no system directory here.

$> ls -al
total 28
drwxr-xr-x  7 root root 4096 Aug 19 13:37 .
drwxr-xr-x 44 root root 4096 Aug 20 14:28 ..
drwxr-xr-x  2 root root 4096 Aug 19 13:37 catalog
drwxr-xr-x  2 root root 4096 May 26 02:07 network
drwxr-xr-x  2 root root 4096 Aug 19 13:37 ntp-units.d
drwxr-xr-x  2 root root 4096 Aug 19 13:37 user
drwxr-xr-x  2 root root 4096 May 26 02:07 user-generators
  • The second link did say that right . On systemd systems, one can see this in the /usr/lib/systemd/system/[email protected] unit file, which reads Environment=TERM=linux
    – neuron
    Commented Aug 20, 2015 at 19:26
  • @neuron Yeah I thought that might be where it should be but see my edits to the question. That file does not seem to exist on this system. FWIW it was a fresh installation of 8.1.
    – 111---
    Commented Aug 20, 2015 at 19:33
  • Yup, @yaegashi is right
    – neuron
    Commented Aug 20, 2015 at 19:48

2 Answers 2


I suppose TERM is set to linux for the init process (pid 1) by Linux kernel here and there. You can see it in /proc/1/environ (sorry the following output is from Ubuntu 15.04):

$ sudo strings /proc/1/environ 

On Debian/Ubuntu systemd based systems it gets propagated to child getty processes by definitions in /lib/systemd/system/[email protected].

# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM

So you might be able to override TERM in the kernel command line. Try to edit /etc/default/grub and run update-grub and reboot.

  • Thanks, the file I was looking for was /lib/systemd/system/[email protected] and your suggestion for modifying the GRUB_CMDLINE_LINUX works nicely to change this. The system is running on embedded hardware so there will only be one serial console. Thanks.
    – 111---
    Commented Aug 20, 2015 at 20:08
  • @111--- As of 2024 (since when?) systemd sets the serial console $TERM based on /lib/systemd/system/[email protected] . e.g.: One needs to add Environment=TERM=linux at the start of the [Service] section Commented Mar 22 at 18:20

The $TERM variable is normally set in /etc/profile or .bashrc depends on the distro ur using.

Read http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-11.html

  • /etc/profile just sets $PATH and $PS1 and my .bashrc does not seem to explicitly set the $TERM variable.
    – 111---
    Commented Aug 20, 2015 at 18:19
  • What is the content of /etc/profile.d/ ? Can u find with cat and grep on TERM to see if there are files/scripts that sets the environment for TERM ?
    – Ray BSD
    Commented Aug 20, 2015 at 19:15
  • Debian does not do this. It also does not make sense to do so, since your shell has no information whatsoever what the right value should be. Commented Aug 22, 2015 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .