Your Search Bar For Shrewd Tips

How Do I Clear Cmd Terminal?


If your Command Prompt window is crowded with old commands and output, you can clear it in seconds. In Windows Command Prompt, type cls and press Enter. This clears the text displayed in the terminal and gives you a fresh-looking screen, but it does not close Command Prompt or delete files. The right method can vary depending on whether you use classic Command Prompt, PowerShell, Windows Terminal, or a Mac or Linux terminal, so this guide explains the options and what “clear” really means.

How to Clear the Command Prompt Screen

To clear the screen in classic Windows Command Prompt, use the built-in cls command:

cls

Follow these steps:

  • Open Command Prompt. You can search for “Command Prompt” or “cmd” in the Windows Start menu.
  • At the prompt, type cls.
  • Press Enter.

The text currently visible in the Command Prompt window disappears, and you can continue entering commands at the prompt. You do not need administrator access to use cls. It works in a standard Command Prompt window and in a Command Prompt tab opened inside Windows Terminal.

Make sure you type the letters c, l, and s—not “c,” the number one, and “s.” The command is short, so it is easy to mistype. If the screen does not clear, check that you are at a command prompt and that the command has no extra characters, then press Enter again.

What Does the CLS Command Do?

CLS stands for “clear screen.” It removes the text currently displayed in the Command Prompt window, including earlier commands and their output in the visible area. It does not restart the command-line session, change folders, stop a running program, or undo anything you have done.

For example, if you run a directory listing and then clear the screen, the files and folders are no longer visible in the window. They are still on your computer, and the command history may still let you recall commands you typed. Clearing the display is different from deleting data or clearing every record of your activity.

The command is also different from closing Command Prompt. After running cls, you can carry on using the same session. Your current working directory and environment settings remain as they were before the screen was cleared.

How to Clear the Screen in PowerShell

PowerShell has a similar command for clearing its display. Enter either of these commands and press Enter:

Clear-Host
cls

In PowerShell, cls is an alias for Clear-Host, so either option works in a regular interactive session. You may also see clear used as an alias in PowerShell. If you are following instructions written for a particular shell or script, use the command specified there, since aliases and screen-clearing behavior can vary across environments.

PowerShell can run inside the Windows Terminal app, just like Command Prompt. The command you enter depends on the shell running in the tab: use cls or Clear-Host in PowerShell, and cls in Command Prompt.

How to Clear a Terminal on Mac or Linux

On many Mac and Linux terminal shells, type clear and press Enter:

clear

This clears the visible terminal screen. The keyboard shortcut Ctrl+L also works in many terminal applications and shells. On a Mac keyboard, press Control and L—not Command and L. The shortcut may not behave the same way in every app or shell, so use the clear command if it does not work.

These instructions apply to Unix-style shells such as Bash and Zsh. They are not the standard commands for classic Windows Command Prompt. If you are unsure which shell you are using, look at the prompt or check the application’s title bar, then choose the command for that environment.

Does Clearing the Screen Delete Command History?

No. A screen-clearing command generally removes text from view; it does not erase the shell’s command history. In Command Prompt, you may be able to move through previously entered commands with the Up and Down arrow keys after using cls. PowerShell and other shells can also keep command history, depending on their settings.

Clearing the screen is not a privacy or security feature. It does not securely erase sensitive information from your computer, remove saved history, delete terminal logs, or guarantee that text cannot be recovered from the application or system. If you entered a password or other secret directly into a command, clearing the display does not undo that exposure. Avoid typing sensitive values into commands where they could be saved or displayed, and follow your organization’s approved process for handling confidential information.

How to Clear Scrollback or the Terminal Buffer

Some terminal applications retain earlier output in a scrollback buffer. This means that even after running cls or clear, you might still be able to scroll upward and see text that was previously displayed. That is because clearing the visible screen and clearing the scrollback buffer are separate actions.

The way to clear scrollback depends on the terminal application. Check its menus, keyboard shortcuts, or command palette for an option such as “Clear buffer” or “Clear scrollback.” In Windows Terminal, available actions can depend on the app version and configuration; open the command palette or settings to see which clear-buffer actions are available. If you use a different terminal app, consult its help or documentation rather than assuming that cls removes the scrollback.

On some Unix-like terminals, a control sequence can request that the display and scrollback be cleared:

printf '\033[3J\033[H\033[2J'

Whether this works depends on the terminal emulator and its settings. It is not a universal solution, and it does not erase command history or system logs. For ordinary use, the built-in clear command and the terminal’s own clear-buffer option are usually the simplest choices.

Why Is CLS Not Working?

If typing cls does not appear to clear the screen, check these common causes:

  • You are using a different shell. cls is the standard screen-clearing command in Windows Command Prompt. In a Mac or Linux shell, try clear.
  • A program is still running. If an application is actively printing output, it may immediately fill the screen again. Wait for it to finish or stop it using the program’s normal method before clearing the display.
  • The command was mistyped. Enter cls with no spaces or extra punctuation, then press Enter.
  • You expect the scrollback to disappear. The visible screen may clear while older output remains available when you scroll up. Use the terminal app’s clear-buffer feature if you need to remove that display history.
  • The terminal is in a special mode. Some programs temporarily take control of the screen, such as text editors or interactive tools. Exit the program normally before entering a shell command.

If you are not sure whether the tab is running Command Prompt or PowerShell, open a new tab and choose the shell you want, or check the tab’s profile. The command cls works in both standard Command Prompt and PowerShell, but other shell commands may differ.

Can You Clear Command Prompt Automatically?

You can type cls whenever you want a clean display. You can also place it in a batch file to clear the screen when that file runs. For example:

@echo off
cls
echo The screen has been cleared.

In a batch file, @echo off prevents the commands from being printed as they run, cls clears the display, and echo prints a message. Use this only when you want the screen cleared as part of the batch file’s normal behavior. It does not clear command history or securely remove information.

Be cautious about copying commands or scripts from unfamiliar sources. A screen-clearing command is harmless by itself, but other commands in the same script might make changes to files or system settings. Read a script before running it, especially if you do not recognize the commands it contains.

Quick Reference: Clear Commands by Terminal

  • Windows Command Prompt: cls
  • Windows PowerShell: Clear-Host or cls
  • macOS Terminal: clear or, in many shells, Ctrl+L
  • Linux terminal: clear or, in many shells, Ctrl+L
  • Terminal scrollback: Use the terminal application’s clear-buffer or clear-scrollback action, if available.

These commands clear the display, not your files. If an instruction tells you to run a command to clear the terminal, confirm that it matches the shell you are using before entering it.

Conclusion

To clear the Windows Command Prompt screen, type cls and press Enter. Use Clear-Host or cls in PowerShell, and clear in most Mac and Linux terminals. Remember that clearing the screen only removes visible text; it does not delete files, erase command history, or necessarily clear the terminal’s scrollback buffer. For a quick refresh, the appropriate clear command is usually all you need.


Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

Shrewdnia

Shrewdnia

Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

Back to blog

Leave a comment

JOIN THE SHREWDNIA COMMUNITY FORUM

What do you think?

Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

Join the Forum →