After running a few verbose commands like ls -l or viewing the contents of a long text file with cat, your Linux terminal screen can quickly become cluttered with a massive wall of text. Trying to locate your command prompt in this visual mess is frustrating. Instead of opening a brand new terminal window, you can instantly wipe the screen completely clean using the clear command.
How to Use the clear Command
Using the command is incredibly straightforward. Whenever your terminal screen is too messy, simply type the following word and press Enter:
clear
Instantly, all the previous output will vanish, and your command prompt (e.g., user@hostname:~$) will jump to the very top left corner of the pristine, empty window.
How It Actually Works (And the Hidden Shortcut)
It is important to understand that the clear command does not actually delete your command history or destroy the previous output. It simply prints a series of invisible “newline” characters that push all the old text upward, entirely out of the visible frame of the window.
If you use your mouse to scroll up in the terminal window, you will find that all of your old commands and their outputs are still there, perfectly preserved.
The Pro Shortcut: Typing out the word “clear” five times an hour can get tedious. Instead, you can use the built-in keyboard shortcut. Pressing Ctrl + L on your keyboard will instantly execute the clear command, regardless of what you are currently typing on the prompt.