Open In App

Clear Command in Linux with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

clear is a standard Unix computer operating system command that is used to clear the terminal screen. This command first looks for a terminal type in the environment and after that, it figures out the terminfo database for how to clear the screen. And this command will ignore any command-line parameters that may be present. Also, the clear command doesn’t take any argument and it is almost similar to cls command on a number of other Operating Systems.

Syntax of the `clear` command in Linux 

clear

Using the `clear` command to clear the terminal in Linux.

Terminal Before Executing clear command: 

clear-command-in -linux

clear-command-in -linux

 Terminal after Executing clear command:

clear-command-in-linux

clear-command-in-linux

Clearing our terminal using `clear -x` in Linux System

Syntax:

clear -x

Terminal before using `clear -x` in Linux

clear -x

clear -x

Terminal after using `clear -x` in Linux

clear -x

clear -x

Clear Using `CTRL + L` Shortcut in Linux System.

We can clear our terminal by using short cut `CTRL+L`.

For GNOME terminal in ubuntu 18.04 press `shift + ctrl + alt + c`.

Using `reset` command to clear our terminal in Linux System.

We can clear our terminal using the command `reset` in Linux.

Syntax:

reset

Using `\ec` command to clear our terminal in Linux System.

We can clear our terminal by using command `\ec“`

Syntax:

printf "\ec"

Where `\e` represent the ESC character and `c` is an escape sequence that is recognized by some terminal emulators to clear the screen.

This command is used in some specific terminals only.

What is the difference between `clear` and `reset` command.

The `clear` command clears the terminal screen only while when talk about `reset` command, it not only clear the screen but also resets the terminal’s settings to their default values.

Conclusion

In this article we have discussed the `clear` command and different ways to clear our terminal screen in Linux. One can easily understand these commands and with no effects can clear their terminal screen anytime.


Last Updated : 09 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads