Friday, December 2, 2011

Set backspace key for erasure on unix

Sometimes when we try to use backspace key on a unix terminal, it does not work as expected. Instead it prints caret and some special characters on command prompt.

There are two ways to handle it:
  • Add below command in .profile of the user account.
                          stty erase ^?
  • Run the following command. It will only set the backspace key for current session.
                          stty erase "press backspace key to print special characters"
          OR           stty erase ^?

stty command is used to set the terminal options. For detailed information, you can check its manual on unix by running command man stty