Sometimes my R & D result in the weird output on the 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. This article describes how to really clear the terminal screen or reset terminal in Linux or Unix-like system. In other words, you will learn how to clear console garbage and gibberish without exiting the session on your Linux/Unix/macOS/BSD systems.
How to Fix Console Garbage and Gibberish on Linux and Unix
There are multiple commands to fix console gibberish or garbage. Let us see all commands and usage in details.
The clear command
The clear command clears your screen including its scrollback buffer.
You can press CTRL+L to clear screen too. However, clear command won’t clear the terminal screen. Use the following methods to really clear the terminal so you get a get back a good working terminal.
How to fix the display using the reset command
Here is my console with gibberish all over the screen:
To fix the display just type the reset command. It will initialization terminal again for you:
$ tput 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 the clear command):
Use ANSI escape sequence to really clear the bash terminal
Another option is to type the following ANSI escape sequence:
clear echo -e "\033c"
Sample outputs from both commands:
This page showed how to fix your console when in garbage and gibberish state. This will clear your console without exit the whole session and restart. Now that you know how to reset screen to normal mode. Read man pages of stty and reset command here for more information bash(1).
🐧 11 comments so far... add one ↓
|Category||List of Unix and Linux commands|
|Disk space analyzers||ncdu • pydf|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||NetHogs • dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|