Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Clear Command Prompt (CLS & More)

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To clear the Command Prompt window, type cls and press Enter. That's the built-in command that wipes all previous text from the screen, giving you a clean slate. If you want to clear the entire command history or reset the prompt's environment, there are a few extra steps—but cls is the core answer.

What You'll Need

  • A Windows PC (any version from Windows 7 to Windows 11).
  • Access to the Command Prompt—either a standard user or administrator window (the steps are the same for both).
  • No special tools or downloads are required; everything is built into Windows.

Step-by-Step

  1. Open Command Prompt. Press Win + R, type cmd, and press Enter. Alternatively, search for “Command Prompt” in the Start menu and click it.
  2. Type the clear command. At the prompt, type cls (lowercase or uppercase doesn’t matter) and press Enter. The screen will instantly clear, leaving only the prompt line (e.g., C:\Users\YourName>) at the top.
  3. Use the shortcut (optional). If you prefer not to type, you can also press Ctrl + L in most Windows terminal applications (including the classic Command Prompt in Windows 10 and 11). This does the same thing as cls.
  4. Clear the command history (optional). The cls command only clears the visible screen, not the history of commands you’ve typed. To clear the history so you can’t scroll back through previous commands, press Alt + F7 (this works in the classic console). If you’re using Windows Terminal (the newer app), you can clear the history by clicking the down arrow next to the tab and selecting “Clear History” or by using the command Clear-History in PowerShell, but in classic Command Prompt, Alt + F7 is the shortcut.
  5. Exit and reopen (nuclear option). If you want a completely fresh session—clearing the screen, history, and any temporary environment variables—just type exit and press Enter, then open Command Prompt again. This is the most thorough way to “clear” everything.

Common Mistakes

  • Typing “clear” instead of “cls”. On Linux or macOS, the command is clear, but in Windows Command Prompt, it’s cls. Typing clear will give you an error: “'clear' is not recognized as an internal or external command.”
  • Forgetting to press Enter. Typing cls without pressing Enter does nothing—the command won’t execute until you hit Enter.
  • Using cls in PowerShell. In PowerShell, cls is an alias for Clear-Host, so it works, but if you type clear it also works because it’s an alias. However, in classic Command Prompt, only cls works.
  • Expecting cls to clear history. As mentioned, it only clears the visible screen. If you press the up arrow, you’ll still see previous commands.

Tips

  • Use cls in batch files. If you write a batch script, adding cls at the beginning will give a clean output every time the script runs.
  • Customize the prompt after clearing. After clearing, you can set a custom prompt by typing prompt $P$G (the default) or something like prompt MyPC> to personalize it.
  • Clear the screen in Windows Terminal. If you use Windows Terminal (the modern app), cls works the same way, and you can also use Ctrl + Shift + W to close the tab, but that’s not the same as clearing.
  • Use cls to reduce clutter. When running long commands or scripts that produce lots of output, clearing the screen before each run helps you focus on the latest results.

Troubleshooting

If cls doesn’t work as expected, try these steps in order:

  1. Check that you’re in Command Prompt, not PowerShell. Both accept cls, but if you’re in PowerShell and it fails, try Clear-Host instead. To see which shell you’re in, look at the title bar—it usually says “Command Prompt” or “Windows PowerShell.”
  2. Restart Command Prompt. Close the window and reopen it. Sometimes the console gets into a weird state, and a fresh start fixes it.
  3. Run as administrator. If you’re having issues with commands not responding, right-click Command Prompt and select “Run as administrator.” This gives full access and often resolves glitches.
  4. Update Windows Terminal. If you’re using Windows Terminal and cls isn’t clearing, check for updates in the Microsoft Store, as older versions had bugs.
  5. If the screen still shows text after typing cls, it might be a display issue. Try resizing the window or minimizing and restoring it. If that fails, restart your computer—rarely, the console driver can hang.

Frequently Asked Questions

Does cls delete any files or data?

No. cls only clears the text on the screen. It does not affect files, folders, or any data on your system.

What’s the difference between cls and exit?

cls clears the screen but keeps the session open. exit closes the Command Prompt window entirely, ending the session. If you want a clean slate without closing, use cls.

Can I clear the screen in PowerShell with cls?

Yes, cls is an alias for Clear-Host in PowerShell, so it works exactly the same way.

Why does my Command Prompt show “The system cannot find the path specified” after clearing?

That error is unrelated to cls. It usually means a command you ran earlier referenced a directory that no longer exists. Check the current directory by typing cd and verify the path is correct.

Is there a way to clear the screen automatically after each command?

No built-in option does that automatically. You could create a batch file that runs cls after each command, but that’s not practical. Instead, just press Ctrl + L whenever you need a clean screen.

Does cls work in Windows 11?

Yes, cls works in all modern Windows versions, including Windows 11, whether you use the classic console or Windows Terminal.