≡ Menu

BASH – Fix The Display and Console Gibberish on a Linux / Unix / OS X / BSD Systems

Sometime my R & D result into weird output on screen. For example, accidentally I run cat command over binary file – cat /sbin/*. You will be not able to access your bash/ksh/zsh based terminal. It will be full of wired character sequences that can lock down your display. These characters will hide what you type or character displayed into strange symbols. To clear gibberish all over the screen use the following method.

Method #1: Fixing the display

Here is my console with gibberish all over the screen:

Fig.01: Bash fix the display

Fig.01: Bash fix the display

To fix the display just type the reset command. It will initialization terminal again for you:
$ reset

If reset command failed to work type the following command to restore the session to a normal state:
$ stty sane

Press CTRL + L to clear the screen (or type clear command):
$ clear

Method #2: Use ANSI escape sequence

Another option is to type the following ANSI escape sequence:

echo -e "\033c"

Sample outputs from both commands:

Animated gif 01: Fix Unix Console Gibberish Command Demo

Animated gif 01: Fix Unix Console Gibberish Command Demo

Read man pages of stty and reset for more information stty(1), reset(1), bash(1)

Share this on:
{ 11 comments… add one }
  • Joe August 9, 2006, 3:32 pm

    I can’t count the number of times I’ve screwed my terminal up like this. Usually I just close the window. Thanks for the fix!

  • raj August 10, 2006, 9:21 am

    same here joe. I use to close bash window.

    this is great fix

  • nixCraft August 10, 2006, 9:29 am

    Glad to know *this display fix* is helping all of you.

    Appreciate your feedback

  • quantumtroll February 11, 2008, 1:47 pm

    This did not work for me. I guess I’m stuck killing the terminal and starting over, but I don’t understand what could go so awry that stty and reset don’t help…

  • antonio luna March 10, 2009, 2:37 am

    Hi. I know this sounds stupid. But I would like to know, Where or what subject it. I can search while looking for classes so I can learn how to run Line Print Terminals.
    I worked as a temp on a Mill for a few month operating a locomotive. while working there, I notice that came to fix the machinery got paid 200 $ hour. I want that money!!.

  • Tony February 23, 2013, 11:17 pm

    @antonio lol …what..?

  • bonzodog December 9, 2014, 10:29 am

    One thing you missed: the possibility that the RET key has gone to Valhalla. Use Control-J to generate line feeds if it doesn’t work.

  • Dave December 10, 2014, 1:38 pm

    Sometimes I use “tput sgr0”, but it doesn’t always work.

  • Dave December 10, 2014, 1:41 pm

    I think the author meant “weird” instead of “wired character sequences” ;-)

  • Frank December 10, 2014, 3:22 pm

    The following command also works:
    cat /bin/ls

  • Anonymous brother October 29, 2016, 2:37 pm

    tput sgr0

    This rules.

Security: Are you a robot or human?

Leave a Comment

   Tagged with: , , , ,