Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

Fixing Terminal Settings with stty

Another handy thing you can do with your shell is use it to fix those annoying problems that occur with terminal programs. Back in Chapter 1, we mentioned that you might encounter oddities such as your backspace.jpg and delete.jpg keys not working properly. You can fix these problems using stty (see Code Listing 3.16).

Code Listing 3.16. You can often straighten out a confused telnet program or Unix system by using a stty command. This one fixes the errant key.

xmission>  ls ^?^?^?^?
   : No such file or directory
xmission>  stty erase '^?'
xmission> ls

Code Listing 3.17. The stty command here fixes the key to work like .

xmission> jf^H^H
jf^H^H: Command not found
xmission> ls ^H^H
: No such file or directory
xmission> stty erase '^H'

To fix and key oddities with stty:

  • stty erase '^?'

    If you're used to backspace.jpg erasing characters to the left of the cursor and you just get a bunch of ^? symbols on the screen when you try it, you need to educate the terminal about your preferences. Type stty erase backspace.jpg to fix it (Code Listing 3.16).

    In some cases, depending on your terminal program, you might need to set stty erase '^H' and then use ctrlh.jpg to backspace. To enter this command, type stty erase '^V' ctrlh.jpg (Code Listing 3.17).

To fix general terminal weirdness with stty:

  • stty sane

    Typing stty sane at the shell prompt will fix a lot of oddities. For example, if you accidentally issue a bad command and all of a sudden nothing shows up on the screen or if you have general gibberish showing up on the screen, stty sane may return your terminal session to sanity.

    The reset command is also often effective at fixing a messed up terminal.

  • + Share This
  • 🔖 Save To Your Account