When you are working in the Linux terminal for an extended period, running multiple commands and viewing long log files, your screen can quickly become a cluttered mess of text. Finding the prompt to type your next command can become difficult. Fortunately, Linux provides a very simple way to wipe the screen clean.
Method 1: The ‘clear’ Command
The most common and straightforward method to tidy up your workspace is using the dedicated clear command.
clear
When you type this command and press Enter, all the previous output is pushed up out of view, and your command prompt is reset to the very top left corner of the terminal window. Technically, the old text is not deleted; if you use your mouse to scroll up, you can still see your previous commands.
Method 2: The Keyboard Shortcut (Ctrl + L)
If you prefer not to interrupt your typing by typing an entire command, there is a keyboard shortcut that achieves the exact same result.
Simply press Ctrl + L on your keyboard. This shortcut immediately pushes the text up and resets the prompt to the top of the screen, just like the clear command.
Method 3: Resetting the Terminal Completely
If your terminal is behaving strangely (for example, if you accidentally tried to cat a binary file and your terminal is now outputting gibberish characters), simply clearing the screen might not fix the underlying display issue. In these cases, you need to completely reinitialise the terminal environment.
reset
The reset command not only clears the screen but completely wipes the scrollback buffer and resets all terminal variables to their default state. This takes a second or two longer than clear but will fix any graphical corruption issues you might be experiencing.