cls command (Windows / CMD)
What it does
Clear visible text from the Command Prompt screen. Searches for the cls command cmd clear screen usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Clear visible text from the Command Prompt screen.
Syntax
cls
Common options
| Flag / option | Meaning |
|---|---|
| cls | Clear the current console buffer view. |
| & cls | Clear after another command on the same line. |
| echo text & cls | Demonstrate CMD command chaining. |
Practical examples
Clear screen
cls
Clears the visible Command Prompt window.
Clear after pause
pause & cls
Waits for a key, then clears.
Batch refresh
:refresh cls echo Status updated
Clears before redrawing batch status.
Common mistakes
- Expecting cls to erase command history.
- Using cls to hide sensitive output that remains in logs or captured buffers.
Related commands
- echoDisplay text or control command echoing in a batch script.
- historyDisplay or modify the current shell's command history.
- Get-HelpDisplay syntax, parameter details, examples, and conceptual PowerShell help.
- Get-CommandDiscover commands, aliases, functions, scripts, and applications available to PowerShell.
- ForEach-ObjectRun a script block for each object arriving through the pipeline.
- manRead installed manual pages for commands, formats, and APIs.
FAQ
What does cls do in Command Prompt?
Clear visible text from the Command Prompt screen.
How do I run cls in CMD?
Open Command Prompt and follow `cls`; quote paths containing spaces.
What is a practical cls example in CMD?
Try `cls` — Clears the visible Command Prompt window.
Can cls be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.