How To Clear Command Prompt

Are you new to using Command Prompt and want to learn how to clear it?

Option 1: 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.

Method 1: Clear a Windows Command or CMD Screen

  1. 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).

You can also use the Backspace key on your keyboard.
How to Clear Command Prompt in Windows

The screen now clear of the command!

  1. 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.

Method 2: 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.

The Alt key is usually on the bottom of the keyboard (close to the Space bar). The F7 key is on the top row of the keyboard.
How to Clear a Windows Command Prompt History
After pressing Alt+F7, if you press the up arrow key, you will no longer be able to list the previous commands you executed.

Option 2: 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.

Method 1: Clear a Linux Command or Shell Screen

  1. 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).

How to Clear Command Prompt in Linux
How to Clear Command Prompt in Linux
  1. 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!

Method 2: 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.

After executing history -c, if you press up arrow key, no previous command will be displayed. To delete a particular command from the history, enter history -d <command-line-number>

Conclusion

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, 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, for more Windows 10 Itechguides, visit our Windows 10 How-To page.

  • Was this page helpful?
  • Yes (6)No (2)

Tag » How To Clear Command Prompt