How to Clean Terminal in Ubuntu
Too much output on the terminal screen? How about cleaning it all in one go?
The easiest way to clean your terminal is to press the Ctrl + L
shortcut:
You can achieve a similar behavior using the clear
command as well.
While they both appear to do the same thing on paper, there's a huge difference between how they operate and most users aren't aware of this.
So in this tutorial, what I'm going to do is explain both methods and then share the difference between them.
Clean terminal in Ubuntu
There are 2 ways you can clean your terminal in Ubuntu:
- Using the
Ctrl + L
shortcut - Using the
clear
command
But as I mentioned earlier, they both work differently. So I will get into more details to help you choose the best solution for your use case.
Using the Ctrl + L shortcut
Using the Ctrl + L
shortcut is the most popular way of clearing the terminal screen but does not wipe out the previous operation.
It just jumps you to the new empty black prompt which looks like the screen was cleared.
Let me show you:
As you can see, when I pressed Ctrl + L
, it cleared the screen but when I scrolled up. it showed the previous output.
So in simple terms, it does not clear the screen but jumps you to the blank screen while keeping every previous output which can be accessed by scrolling up.
The best part is being a shortcut, this action won't be registered in the command history also the convenience you get is far better than executing a command for similar behavior.
In simple terms, if all you want is a blank screen to work with and you don't care about whether it cleared the terminal in the true sense or not, you must use it!
(this is what I personally use, no issues so far).
Using the clear command
"Clears the terminal in a true manner" that's all I have to say about this command.
Unlike the Ctrl + L
command, which does nothing but give you a blank prompt while keeping the previous output, the clear command, clean everything.
To use this command, simply execute the clear
command like you do with the other commands:
clear
After executing the clear
command, I tried scrolling up but it showed no previous output which is a big plus compared to the other method.
But as it is a command, it will be stored in the command history:
So if you are ok with that, you can use it!
Elevate your terminal experience with zsh
Tired of that old boring terminal prompt? I know exactly how you can make it modern and useful.
For that, you can use zsh, a modern shell that allows you to add plugins and themes to your prompt. Here's how you can use zsh in Ubuntu:
I hope you will find this guide helpful.