Many a times it happens that the terminal in Linux gets filled with outputs from previous commands. It makes the terminal display chaotic and unorganised, especially when the previous output is no longer required by the user. Hence, it is a good practice to clear the terminal screen after it gets filled.
There are multiple ways to clear terminal in Ubuntu and Linux distributions. Let’s explore them one-by-one.
Ctrl + L
Key Combination
The easiest and simplest way to clear the terminal screen is by pressing the key combination Ctrl + L
.
Note that, this is a default combination. Linux allows user to assign a script/program to a key combination. Hence, the above combination must not be used as a custom combination for something else, for it to work on the terminal.
clear
Command
The Clear command also clears the terminal in a similar way as described above. User has to simply run the clear
command to clear the screen.
Note that in both the above methods, the outputs displayed previously on the screen can still be seen by scrolling the terminal up.
reset
Command
The reset
command is used to initialise the terminal again. It will, hence, also clear the screen.
The difference in this method is that, due to re-initializing, it is now a new terminal. Hence, the user cannot scroll up to see the older outputs in this case.
Ctrl + Shift + K
Combination in Konsole
If you are using the desktop environment KDE, the default terminal program is Konsole. Users can also install and use Konsole in other desktop environments.
Along with the methods described above, there is the key combination Ctrl + Shift + K
which can be used to clear screen in Konsole. This default combination is basically a shortcut for the reset command.
Adding Shortcut for reset
command in Ubuntu terminal
Similar to Konsole’s default key combination for reset
command, you can add a key combination for reset
in the Gnome terminal in Ubuntu.
Go to Terminal » Preferences.
Go to the ‘Shortcuts’ tab, scroll down until you see ‘Reset’ options.
Double click on Reset. It will ask you to press the key combination. Verify if the combination you pressed was assigned to Reset.
We have described some ways to clear and reset a terminal screen in this article. Hope you find them useful.
Member discussion