Ever felt that your command line (Windows PowerShell & Command Prompt) is too messy and there’s too much information for you to process? Well! This can be irritating for some users. However, nothing to worry about, you can clear your command line screen via the “cls” command and a few additional methods (for Windows PowerShell) as discussed in this detailed guide.

Quick Outline:

How to Use the “cls” Command in Windows?

The “cls” command clears the Command Prompt and Windows PowerShell’s screen right after you execute it. It has no options/flags and there is no way to customize it. To clear the command-line screen (Windows PowerShell & Command Prompt), use the “cls” command as follows:

cls

In Windows PowerShell, you can use the “clear” command as well as an alternative to the “cls” command to remove/clear all the text from the screen:

clear

Additionally, you can use the “ALT + L” keys (in the Windows PowerShell only) to clear the screen. This saves the time required to type the “cls” or “clear” command. On the other hand, the Command Prompt does not support any shortcut keys to clear the screen.

Note: You can use the “escape” key to remove the current line (where the cursor is blinking).

Bonus Tip: View and Save the Command Line History

If you accidentally used the “cls” or “clear” command and now you want to see what commands you executed? It is possible by using the following command:

doskey /history

If you want to save the command history for later use, execute the following command and replace the “filename.txt” with the file in which you want to save the commands history:

doskey /HISTORY > filename.txt

That’s all for using the “cls” command in Windows.

Final Words

The “cls” command clears the text including the commands executed and their output from the command line (Windows PowerShell and Command Prompt). In Windows PowerShell, you can use the “ALT + L” keys as a shortcut to clear the text. You can view the cleared command history by using the “doskey /history” command. This guide has shed light on the “cls” command of Windows.