`reset` command makes backspace unusable

崔灏 (CUI Hao) cuihao.leo at gmail.com
Tue May 29 09:10:03 UTC 2018

Hi, new to FreeBSD. On Linux, I often use `reset` command to recover
an broken terminal. On FreeBSD, `reset` seems to render backspace
unusable in some CLI programs.

Steps to reproduce the problem:
1. SSH login FreeBSD server from a Linux terminal emulator. TERM is
set to `xterm-256color`.
   I tried Konsole / Termite. Both reproducible.
   But xterm/uxterm doesn't trigger the problem.
2. Executing `reset` on FreeBSD.
3. Then pressing backspace will yields `^?`  instead of backward
delete in most CLI programs including bash/vim/cat, but not tcsh and

Like this:
wm at wmc:~$ reset
Erase is backspace.
wm at wmc:~$ ^?^?^?^?    # typing backspace...

I googled about the problem. `stty erase ^?` after `reset`, or `reset
-e ^?` fix it. But I still wonder why `reset` doesn't work like on
Linux. I do some investigation, here are some of my observations:

1. terminal line settings (`stty -a`)
I checked the output of `stty -a`. On Linux terminal (Termite), I saw
`erase = ^?`. For full output, see https://cfp.vim-cn.com/cbff6

After SSH login FreeBSD, `stty -a` shows `erase = ^?; erase2 = ^H`,
which seem to be consistent with Linux. See

But after `reset`, the settings changed and becomes `erase = ^H;
erase2 = ^H`. see https://cfp.vim-cn.com/cbff8

2. termcap
It seems default terminal line settings are determined by termcap db.
I checked `/etc/termcap` and found the entry of `xterm-256color`,
which inherits settings of `xterm-basic` entry. `xterm-basic` sets
On Linux, I get the termcap settings by `infocmp -Cr`. Terminal
`xterm-256color` sets `kb=^H`, while `xterm-termite` sets `kb=\177`.

I tried to override FreeBSD termcap settings in `~/.termcap`:
xterm-256color|xterm alias 3:\

Above settings indeed works and `reset` won't alter erase setting.
However, Linux `xterm-256color` termcap does set `kb=^H` like FreeBSD,
but it doesn't cause the problem on Linux.

Although I have found several workaround to fix backspace problem, may
anyone explain why terminal settings inconsistent on Linux and
FreeBSD? Is this a bug or just some compatibility issues? Are there
other compatibility issues with Linux terminal emulator?

崔灏 / CUI Hao
Homepage: i-yu.me
Twitter: @cuihaoleo

More information about the freebsd-questions mailing list