How To Clear Command Prompt

Photo of author

By Victor Ashiedu

Published

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

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

  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.

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.

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.

How to Clear Command Prompt in Linux

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

  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!

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.

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>

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.

We go the extra mile to deliver the highest quality content for our readers. Read our Content Writing, Content Review, and Anti-Plagiarism policies to learn more.

About the Author

Photo of author

Victor Ashiedu

Victor is the founder of InfoPress Media, publishers of Ilifeguides and Itechguides. With 20+ years of experience in IT infrastructure, his expertise spans Windows, Linux, and DevOps. Explore his contributions on Itechguides.com for insightful how-to guides and product reviews.

Related Articles

Get in Touch

If this article does not meet your expectations, kindly let us know. We have various ways you can get in touch with us:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend