Are you new to using Command Prompt and want to learn how to clear it? This Itechguide teaches you how to clear command prompt in Windows and Linux.
The guide also covers steps to clear command prompt history in Linux and Windows.
How to Clear Command Prompt in Windows
This section is divided into 2 sub-sections. The first teaches you how to clear a Windows CMD command or screen. The second covers steps to clear Windows Command Prompt command history – delete all previous commands in the current section.
How to Clear a Windows Command or CMD Screen
- If you enter a command you do not intend to in a Command Prompt, to clear the command from the CMD screen, press the Esc key on your keyboard.
In this example, I entered the command cd \, to clear it from command prompt, I will press the Esc key on my keyboard – see the location of Esc key in the second image below (last key on the top left).
The screen now clear of the command!
- However, if you have been running a lot of commands on the current CMD section and want to clear everything off the screen, type cls and press enter.
cls
The cls command clears everything from the Command Prompt screen and gives you a clean screen.
How to Clear Command Prompt History on Windows
As you run commands in CMD, the shell keeps a history of all the commands you have executed in the current section. This makes it easy to call previous commands – using the up arrow key.
To clear command prompt commands from the current section, press Alt and F7 keys on your keyboard simultaneously. Before you press Alt+F7, ensure that Cmd is open and that you clicked your mouse on it.
How to Clear Command Prompt in Linux
This section teaches you how to clear a command you typed but do not intend to execute. You also learn how to clear the entire Linux command shell of everything on the screen – including previous commands and command results. The section also covers steps to clear Linux command shell history.
How to Clear a Linux Command or Shell Screen
- If you enter a command you do not intend to in a Linux shell, to clear the command from the shell’s screen, press the Backspace key several times until the command is cleared from the screen.
In this example, I entered the command vi, to clear it, I will press Backspace key on my keyboard several times – see the location of Backspace key in the second image below (second row, top left – beneath the Delete key).
- However, if you have been running a lot of commands on the current Linux shell and want to clear everything off the screen, type clear and press enter.
Everything on the shell’s screen is gone!
How to Clear a Linux Shell Command History
As you run commands in Linux shell, the shell keeps a history of all the commands you have executed in the current section. This makes it easy to call previous commands – using the up arrow key.
However, to clear all previous commands from the current section, enter history -c and press enter
history -c
This will clear all previous commands from the current shell section.
You can use the methods described in this itechguide to clear command prompt in both Linux and Windows!
I hope you found this guide helpful. If you found this guide helpful, kindly spare 2 minutes to share your experience with our community at [discourse_topic_url].
However, if you have any questions regarding this guide or if the steps did not fix your problem, please post your question at [discourse_topic_url]. Our team and other community members will come back to you with a fix as soon as possible.
Finally, for more Windows 10 Itechguides, visit our Windows 10 How-To page.