How to Clear the Terminal Screen in Ubuntu?
In Ubuntu, the terminal is a command-line interface that allows users to interact with the operating system through a text-based interface. It provides access to the shell, a program that interprets and executes user commands.
Clearing the Ubuntu terminal is important for clarity and security reasons. By clearing the terminal, it becomes easier to read and understand the output of commands, particularly when there is a lot of text on the screen. Additionally, clearing the terminal helps protect sensitive information that may have been displayed in previous commands. This is especially important when working in a shared environment, as it ensures that any sensitive information is not visible on the screen once the command has been executed.
Considering its importance, we will provide various ways to clear the Ubuntu terminal. The whole process of the article is performed on Ubuntu 22.04.
How to Clear the Terminal Screen on Ubuntu?
When the terminal’s output is flooded, it becomes really necessary to clear the terminal to proceed further with the terminal operations effectively. This section lists the possible commands/actions to clear the Ubuntu terminal.
Let’s get into this one by one:
Using the “$clear” Command
To really clear the Ubuntu terminal, just write the clear keyword in the terminal and hit enter. If you look at the terminal, it is quite messy now:
It can be seen that after executing the clear command.
Using tput reset Command
In this example, we will see the practical demonstration of the command given below:
$ tput reset
The screenshot above shows that the “tput reset” has cleared the Ubuntu terminal.
Using the setterm -reset Command
The Ubuntu terminal also allows you to use the command, i.e., setterm -reset, to clear the previous history of the terminal. Run the command given below:
$ setterm -reset
Here is the output result of the command “setterm -rest.” You can see that the terminal content has been removed.
Using stty sane Command
The command “stty sane” works like the “clear” command. The following command can be run to demonstrate clearing the terminal practically.
$ stty sane
As you can absorb that the terminal content is removed successfully.
Using the “Advanced” Option
Along with terminal commands, there is another way to clear the terminal record. The detailed process is as follows:
Go to the Menu on the top right corner of the terminal (as shown below):
In the Advanced tab, click on the “Reset and Clear” option:
Select the Advanced tab (red bounding box):
You can see that the terminal has been cleared:
These are all the methods/commands to clear the terminal.
How to Create a Custom Shortcut to Clear a Ubuntu Terminal?
Shotcut in the Operating Systems is the key to performing any operation quickly. To perform any operation quickly, the shortcut is the best way to do it. So, we are here to guide you on how to create a shortcut to clear the terminal.
The following is the step-by-step process to create a shortcut to clear the terminal instantly:
First, Open the Ubuntu terminal (CTRL+ALT+T), and click on the Preferences option from the Menu:
Inside the Preferences, Click on the Shortcuts option and then on the Terminal, as seen below. In the “Terminal” tab, you will see that “Reset and Clear” is disabled:
Select the “Reset and Clear” Disabled option:
The “New accelerator” option will appear:
Enter a shortcut key of your choice from the keyboard, e.g., CTRL+R, etc:
That’s how you can create a custom shortcut key to clear the terminal.
Note: Enter a combination of keys other than default keys, such as CTRL+C and CTRL+S.
In Ubuntu, clearing the Ubuntu terminal is important for clarity and security reasons. It helps users read and understand the output of commands, particularly when there is a lot of text on the screen.
This article provided various ways to clear the Ubuntu terminal, including using the “clear” command, “tput reset,” “setterm -reset,” “stty sane,” and the “Reset and Clear” option in the terminal menu. Additionally, we also discussed how to create a custom shortcut key to clear the terminal instantly. By following these steps, users can maintain a clean and secure working environment in their Ubuntu terminal.
Keep visiting Linux-Genie for more Linux-based tips and tricks.