When connecting to the Pi by the serial console, I'd like to have the default TERM be xterm, rather than the current default of vt102:

pi@raspberrypi:~$ echo $TERM
pi@raspberrypi:~$ tty

I know I could add this to .bashrc, etc. - but I only want to change the current default, and to otherwise not impact other types of connections.

https://www.debian.org/releases/jessie/i386/ch05s03.html.en seems to indicate that I should be able to add TERM=xterm to the boot parameters - which are at /boot/cmdline.txt. As such, I tried updating the following:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


dwc_otg.lpm_enable=0 console=serial0,115200 TERM=xterm console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

... and then rebooting, but with no change. Now, http://man7.org/linux/man-pages/man7/bootparam.7.html indicates that this may be a "(useless?) example" (for reasons I don't understand).

Now, I did find /lib/systemd/system/serial-getty@.service, which contains the following:

ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM

... but I can't find where the default $TERM is being defined.

I did add the following here:


This is working - but it seems that I'm still missing part of the puzzle here, as to where this is defaulting to vt102, or why this can't be set in cmdline.txt.

(Other sources I've already referenced:)


Had I read the "Docs" section of the output from systemctl status serial-getty@ttyS0.service, it includes a link to http://0pointer.de/blog/projects/serial-console.html . From there:

serial-getty@.service is responsible for all other terminals, including serial ports such as /dev/ttyS0. It differs in a couple of ways from getty@.service: among other things the $TERM environment variable is set to vt102 (hopefully a good default for most serial terminals) rather than linux (which is the right choice for VTs only), and a special logic that clears the VT scrollback buffer (and only work on VTs) is skipped.

So, this is apparently a hard-coded default. This is also supported by the following:

However, for completeness - I'm still searching for where this is actually coded.

  • Xterm is a vt102 terminal emulator for X windows. Your question makes no sense to me. Try another explanation. – PaulF8080 Aug 26 '16 at 2:39
  • @PaulF8080 - it is somewhat ambiguous. In this context, maybe take it to mean that we want the terminal to "function like xterm". See also: unix.stackexchange.com/questions/23764/… and unix.stackexchange.com/questions/43945/… ? – ziesemer Aug 26 '16 at 7:59
  • Xterm and the console both emulate the old DEC VT102 terminal – PaulF8080 Aug 26 '16 at 19:57
  • @PaulF8080 - sure, but xterm is supposed to be a superset of vt220 - while also supporting colors and other features. Bottom line, a lot of things are disabled when TERM=vt102, but work with TERM=xterm. Look at how many bashrc and such files are checking for TERM=xterm various things... – ziesemer Aug 26 '16 at 20:21
  • The vt102 does color and cursor control with ANSI escape sequences. Does that solve your problem, then? – PaulF8080 Aug 26 '16 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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