Do you wish to clear everything on the terminal screen in Linux instantly? Read this guide to learn the numerous ways you can do it.
Option 1: Clear Terminal Screen with the Clear Command
The most common and one of the fastest ways to clear the terminal screen in Linux is to use the clear command. All you have to do is input the command below and press the enter key on your keyboard.
clear
Executing the aforementioned command erases everything on the terminal screen, including the scrollback buffer. In case you are wondering, the scrollback buffer contains data or text that has scrolled off a display and is no longer visible.
In this context, the scrollback buffer features previous texts, commands, and outputs that have been scrolled off the terminal screen. Therefore, if you wish to access the scrollback buffer, you can simply scroll up or use the Pg Up key.
Meanwhile, if you want to erase your Linux terminal screen, excluding the scrollback buffer, you have to add the “-x” argument with the clear command. Below is what the command should look like after adding the “-x” argument.
clear -x
Option 2: Clear Terminal Screen Using the Reset Command
Interestingly, apart from the clear command, you can also use the reset command to clear the terminal screen in Linux. However, unlike the clear command, the reset command reinitializes the terminal and restores it to the default settings.
To make use of the reset command to clear the terminal screen in Linux, input the command below and press the enter key.
reset
Option 3: Clear Terminal Screen with Keyboard Shortcut
Do you know that there is a keyboard shortcut to clear the terminal screen in Linux? Well, if you press the Ctrl + L keys on your keyboard simultaneously, it automatically erases everything on the terminal screen.
Option 4: Clear Terminal Screen Using an Alias
Interestingly, you can use an alias to clear the terminal screen in Linux. For your information, an alias in Linux is a shortcut for an original command.
Therefore, you can create an alias for the actual commands used to erase the terminal screen in Linux. What this means is that even though the clear and reset commands are pretty simple, you can create simpler commands for them.
To create an alias in a Linux terminal, input the subsequent command below and press the enter key. However, replace “new command” with your preferred alias and “actual command” with the original command.
alias new command='actual command'
For example, if I want to set “x” as the alias for the “clear” command, below is what the command will look like.
alias x='clear'
After creating an alias for an original command, the alias will execute as the original command. Therefore, if I execute “x” in my Linux terminal, it will erase the terminal screen just like the “clear” command – remember, I set “x” as the alias for the “clear” command.
To create a permanent alias, you need to edit system files.
Frequently Asked Questions
Input “clear” and press the enter key to erase every content on the terminal screen in Ubuntu. Alternatively, you can use the Ctrl + L keyboard shortcut to erase the content on the terminal in Ubuntu.
Yes, you can install Linux on your Windows 10 computer. To accomplish that, read How To Install Ubuntu In Windows 10.
WSL is a compatibility layer for executing Linux natively on Windows 11, Windows Server 2019, Windows 10, and Windows Server 2022. By the way, the full form for WSL is Windows Subsystem for Linux.
Yes, the Ubuntu application is available on the Microsoft Store.
Yes, Ubuntu is a Linux-based operating system that belongs to the Debian family of Linux.
Conclusion
When working in the Linux terminal, you’ll often find that the terminal screen is filled with too many commands and outputs. Hence, you may want to clear everything on the terminal screen to focus on the next task you plan to perform.
Fortunately, this guide demonstrated multiple methods to erase the terminal screen in Linux. Specifically, we learned how to perform this task using the clear command, reset command, a keyboard shortcut, and an alias.
I hope you found the procedures provided in this guide helpful and easy to understand. If you found the procedures helpful, click on “Yes” beside the “Was this page helpful” question below.
You may also express your thoughts and opinions by using the “Leave a Comment” form at the bottom of this page.
Finally, visit our Linux how-to page to get more Linux guides.