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

by on August 8, 2006 · 7 comments· LAST UPDATED December 9, 2014

in , ,

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)

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 Joe August 9, 2006 at 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!

Reply

2 raj August 10, 2006 at 9:21 am

same here joe. I use to close bash window.

this is great fix

Reply

3 nixCraft August 10, 2006 at 9:29 am

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

Appreciate your feedback

Reply

4 quantumtroll February 11, 2008 at 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…

Reply

5 antonio luna March 10, 2009 at 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!!.

Reply

6 Tony February 23, 2013 at 11:17 pm

@antonio lol …what..?

Reply

7 bonzodog December 9, 2014 at 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.

Reply

Leave a Comment

Tagged as: , , , ,

Previous post:

Next post: