Among the stty -a settings on my machine there are such as erase = ^?; kill = ^U;. The man page reports that

   erase CHAR
          CHAR will erase the last character typed

   kill CHAR
          CHAR will erase the current line

But I found out the corresponding keyboard shortcuts effectively do the same thing, i.e. when I type boo at the terminal and then press <ctrl>+U or <ctrl>+? the line would be erased completely in both cases.

So why the erase character does not erase only the last character?

  • Those settings only applies for commands that don't implement their own line editor. For instance most shells implement their own line editors (and even offer you a choice of several like vi style or emacs/gmacs style). Where do you observe that behaviour? At the prompt of some shell? Then what shell? Jan 29 at 15:05
  • You'd also want to check that your terminal sends the ^? character upon pressing Ctrl+? (see with Ctrl+V followed by Ctrl+? for instance). Jan 29 at 15:08
  • @StéphaneChazelas I use Bash as shell and Gnome terminal as emulator. The Ctrl+V then Ctrl+? examination, indeed, shows that ^_, not ^? was sended. But what does this character mean? Jan 29 at 15:18

1 Answer 1


I just tested this at my shell prompt and got similar results. However, closer examination shows an error.

ctrl+/ (which you might think is ctrl-?) actually produces ctrl-_ which is typically bound to "undo". If you want ctrl-? you need to press ctrl+shift+?. You can test this by typing ctrl+v ctrl+/

Note that the stty command affects terminal editing in "cooked" mode where the undo key doesn't work. So my guess is that you are using a shell like bash that implements its own command line editing, which might honor the stty settings but doesn't have to and adds a lot of fancier editing keys as well.

  • I use Bash as shell and Gnome terminal as emulator. The Ctrl+V then Ctrl+? examination shows that ^_, not ^? was sended, indeed. Is it possible for bash to address this character itself taking into consideration the cooked mode does not allow input to proceed (=to be read by shell) before EOL was received (i.e. before I push the enter key)? Jan 29 at 15:33
  • Bash uses raw mode instead of cooked mode specifically so it can handle keys any way it wants. If you want to test cooked mode, try cat and use ctrl-c or ctrl-d to exit.
    – user10489
    Jan 29 at 15:38

You must log in to answer this question.

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