dcsimg

Open Source Software Investigation -- Stty Settings, Backspace and Delete

By Juliet Kemp (Send Email)
Posted May 3, 2010


A reader, Steve Hampson, suggested another solution to the backspace/delete terminal problem: Try typing stty dec on the offending terminal. Unfortunately, this doesn't work in my case. I had a look into stty to see if I could work out what was going on.

Tip of the Trade: A reader weighs in on the backspace/delete terminal problem. Although the solution doesn't solve the problem at hand, it does lead to some interesting open source software troubleshooting.

stty controls your terminal line settings, and it has a slightly alarming array of options (see the man page for full details). stty -a shows the current settings.

stty dec is shorthand for setting several options at once:

  • echoe: Echo erase characters as backspace-space-backspace. This means that characters will be erased from the terminal when you hit the erase key.
  • echoctl: Echo control characters in hat notation (so Ctrl-C is echoed as ^C).
  • echoke: Echo the KILL character by erasing the whole line.
  • -ixany: Any character restarts output.
  • intr ^c: Ctrl-C sends an interrupt signal.
  • erase 0177: Character 0177 (delete, as shown in this ASCII table) erases the last character typed.
  • kill ^u: Ctrl-U erases the current line.

The relevant one is erase 0177. Since this didn't work for me, I concluded that my backspace key, despite operating as a delete key, wasn't sending 0177. To check this out, I tried stty erase 0072, which should make the : key send backspace. That worked fine (i.e., the command is working). Both decimal or hex codes work; stty erase 127 didn't fix my delete key problem either.

To find out what keycode is actually being sent, one can use showkey or xev. Unfortunately, xev wasn't installed on the problem machine, and showkey works only on a virtual terminal, which I couldn't access via ssh; so that's as far as I got. Suggestions of alternatives welcome!

Thanks to Steve for kicking off this investigation into the bowels of stty.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.