4 Useful Commands to Clear Linux Terminal Screen

Just like any other operating system, Linux also supports a rich Graphical User interface (GUI). In fact, it supports multiple graphical desktop environments such as – GNOME, KDE, Cinnamon, and the list goes on.

However, most Linux administrators and power users prefer to use the command line interface, because it allows us to automate repetitive tasks using the scripts.

One of the trivial downsides of this approach is that often times the terminal gets filled up with the command’s or script’s output. So, in some cases, cleaning up the terminal becomes necessary.

In this guide, we will discuss various methods that allow us to clean up the Linux terminal. After following this guide, Linux users can use one of the methods while working with Linux’s command line interface.

1. Clear Linux Terminal Using clear Command

The clear command is one of the most commonly used commands for clearing the Linux terminal. This command simply clears the terminal screen including its scroll-back buffers.

To understand the usage of the command, let’s execute a few commands in the terminal:

$ echo "Hello, World!"
$ cat /etc/os-release

Now, to clean up the screen, just execute the clear command without any argument:

$ clear
Clear Linux Terminal
Clear Linux Terminal

2. Clear Linux Terminal Screen Using CTRL+L Shortcut

In a similar way, we can use the ctrl+L shortcut to clear the terminal screen. However, this method doesn’t clean up the scroll-back buffers.

To illustrate this, first clear the terminal screen using the ctrl+L shortcut and then scroll up the screen using the mouse:

Clear Terminal Using CTRL+L Shortcut
Clear Terminal Using CTRL+L Shortcut

In this example, we can see the previous output by scrolling up the terminal.

3. Reset (Clear) Linux Terminal Using reset Command

Additionally, we can also use the reset command to clear the terminal screen. Just like the clear command the reset command also clears the scroll-back buffers.

The reset command reinitializes the terminal hence it takes more time compared to the clear command.

$ reset
Reset Linux Terminal Screen
Reset Linux Terminal Screen

4. Clear the Terminal Using the Escape Code

We can use the <ESC>c escape code to clear the terminal. Let’s understand with a simple example.

In bash, we can use the \e escape sequence to represent the ESC character. So, to clear the terminal screen we can use the \ec string with the printf command as shown below:

$ printf "\ec"

In a similar way, we can use the \033 octal number to represent the ESC character. So to clear the terminal, we can use the \033c string with the printf command:

$ printf "\033c"

In addition to this, the hexadecimal number \x1B represents the ESC character. Hence we can use it to clear the screen:

$ printf "\x1Bc"

In this guide, we discussed various methods for clearing the Linux terminal screen. Linux users can use one of the methods as per their choice.

Do you know of any other method for clearing the terminal in Linux? Let us know your views in the comments below.

Narendra K
I'm an experienced and passionate software engineer with in-depth experience in Linux, Distributed systems, DevOps, and Cloud. My expertise lies in back-end web development, and the main languages in my tech stack are Java, Spring, Python, and Go. Iā€™m a lifelong learner and an open-source enthusiast.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply

Leave a Reply to broastedavocado Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.