If your terminal is crowded with old commands and output, you can clear the screen in seconds. On macOS and most Linux systems, type clear and press Enter. On Windows, use cls in Command Prompt or Clear-Host in PowerShell. A keyboard shortcut such as Ctrl+L may also clear the visible terminal on many systems. The right method depends on your operating system and terminal app—and on whether you want to hide the current display or erase more of the terminal’s scrollback.
How Do I Clear in Terminal?
For most users, the quickest answer is to enter the clear-screen command for the shell they are using:
-
macOS or Linux: Type
clear, then press Enter. -
Windows Command Prompt: Type
cls, then press Enter. -
Windows PowerShell: Type
Clear-Hostand press Enter. The shorter commandclearusually works too. - Many terminal apps: Press Ctrl+L to clear or redraw the visible screen.
These options are intended to tidy the display, not remove files or change your system. In most cases, they do not erase your command history, delete previous output from a program, or securely remove information. They simply make the terminal easier to read by moving the current prompt to a clean-looking screen.
Clear the Terminal on macOS
On a Mac, open Terminal or another terminal app, type clear, and press Return. The command works in common shells such as Zsh and Bash, which are often used on macOS. You can also press Ctrl+L in many terminal windows to clear or refresh the visible display.
Clearing the display is useful when a long command or program has filled the window with output. It does not close the current shell or stop a program that is running. If a program is actively printing text, it may immediately fill the screen again. To stop a foreground command, Ctrl+C is commonly used, but it is different from clearing the terminal and may interrupt the work in progress.
The macOS Terminal app also has menu options for managing what is shown. Menu labels and shortcuts can vary by macOS version and app, so use clear when you want a simple command that works across many terminal environments.
Clear the Terminal on Linux
On most Linux distributions, enter clear at the shell prompt and press Enter. It works in popular terminal emulators and shells, including Bash and Zsh. Ctrl+L is another common option. Depending on the terminal app, Ctrl+L may clear the display or redraw it so the prompt appears at the top.
The clear command is usually provided by a system utility that checks the terminal type and sends the appropriate control instructions. That makes it a convenient choice across different terminal programs. If the command is missing, your system may have a minimal software installation or an unusual environment; check your distribution’s package documentation or use the terminal app’s clear-screen option.
In a remote Linux session, such as one opened over SSH, clear generally works as long as the remote system has the command and the terminal type is configured correctly. If the display becomes garbled after a program exits, clearing may not be enough; the reset command can sometimes restore terminal behavior, as explained below.
Clear the Screen in Windows Command Prompt
In the classic Windows Command Prompt, type cls and press Enter. The command clears the visible console area and gives you a fresh prompt. The name is short for “clear screen.” It is the standard Command Prompt equivalent of clear on macOS and Linux.
cls
Ctrl+L is not as consistent in Command Prompt as it is in many Unix-style terminal environments. If it does not work in your Windows console, use cls instead. The available keyboard shortcuts can also depend on whether Command Prompt is running inside Windows Terminal or another host app.
As with other clear-screen commands, cls does not delete files, remove saved command history, or undo commands. It changes what is displayed in the console. If you need to remove sensitive information from a shared or recorded session, clearing the screen may not be enough, because the text could remain in scrollback, logs, screenshots, or session recordings.
Clear the Screen in Windows PowerShell
PowerShell provides the Clear-Host command to clear the console display. Enter it at the prompt and press Enter. In a standard PowerShell session, clear is commonly available as an alias for this command, so either form may work:
Clear-Host
PowerShell commands are generally not case-sensitive, so clear-host works too. If you are using PowerShell inside Windows Terminal, you can also use the terminal app’s own clear-screen option or a supported keyboard shortcut. The exact effect of a shortcut can depend on the app and its settings.
PowerShell’s Clear-Host affects the host display; it does not erase your saved command history or reverse earlier commands. PowerShell history may be stored for the current session or persisted by a configured history feature. Clearing the screen and clearing command history are separate tasks.
Does Ctrl+L Clear a Terminal?
Often, yes. In many Linux and macOS terminal sessions, pressing Ctrl+L clears or redraws the visible screen. It is a quick alternative to typing clear, especially when you are already at a prompt. In some shells, the shortcut is handled by the shell’s line-editing settings; in others, the terminal app handles it.
Ctrl+L may behave differently in a Windows console, a remote session, a text editor, or an application running inside the terminal. If you press it while a program is active, the program may interpret the key itself. If nothing happens, use the command for your environment: clear on macOS or Linux, cls in Command Prompt, or Clear-Host in PowerShell.
Remember that Ctrl+L is not Ctrl+C. Ctrl+C commonly sends an interrupt to a running foreground process. Ctrl+L is normally used to clear or refresh the display. Choosing the wrong shortcut could interrupt a command, so check the behavior of your shell and application if you are unsure.
Clear the Screen or Clear the Scrollback?
“Clear the terminal” can mean two different things. The first is clearing the visible screen so the prompt appears on a fresh display. The second is removing the older lines you can see by scrolling up. The clear command often handles the first task, but it may leave scrollback available in your terminal app.
Scrollback is the buffer of earlier text retained by the terminal window. It is useful when you want to review previous output, but it can make a session look as if it was not fully cleared. To remove that buffer, use your terminal app’s menu or a shortcut specifically described as “clear scrollback.” The exact option depends on the app and its configuration.
Some terminal apps combine clearing the screen and clearing scrollback, while others keep them separate. Check the app’s menus or keyboard-shortcut settings for options such as clearing the terminal, clearing the scrollback buffer, or resetting the terminal. Do not assume a command erased information simply because the screen looks empty.
How to Clear the Terminal With ANSI Escape Codes
Some shells and scripts can send ANSI escape sequences directly to the terminal. For example, this command requests that a compatible terminal clear the visible screen and move the cursor to the top-left corner:
printf '\033[2J\033[H'
This can be useful in scripts or when clear is unavailable, but it is not always the best everyday option. Terminal support and behavior can vary, and this sequence generally does not guarantee that scrollback will be erased. For normal interactive use, clear, cls, or Clear-Host is easier to read and more appropriate for the operating system.
A related utility on many Unix-like systems is tput. The command tput clear asks the terminal database for the right clear-screen capability. It can be useful in scripts that need to work with different terminal types, provided the required system tools and terminal configuration are available.
When Should You Use the Reset Command?
If the terminal is displaying strange characters, has the wrong colors, or appears to have a broken cursor after a program exits, try reset in a compatible Unix-like environment. Unlike clear, which mainly tidies the display, reset attempts to reinitialize terminal settings and restore normal behavior. It may take a moment to run.
Use reset only when you need to recover terminal behavior. It is not the usual command for removing clutter, and it may alter the display more extensively than expected. The command may not be installed or behave the same way on every system, especially in minimal environments or inside specialized terminal applications.
If you are working on Windows, use the options provided by your terminal app or shell rather than assuming that a Unix-style reset command is available. For a normal clean screen, stick with cls or Clear-Host.
Does Clearing the Terminal Delete Command History?
No. Clearing the screen usually does not delete command history. On shells such as Bash, Zsh, and PowerShell, commands may remain accessible through the current session’s history feature, and some configurations save history between sessions. Clearing the display only changes what is shown in the terminal window.
It also does not undo commands or remove output saved elsewhere. A command may have written results to a file, sent data to another service, or appeared in a log. If you ran a command by mistake, clearing the screen does not reverse its effects. Review the command’s behavior and take the appropriate corrective action instead.
If your goal is to remove a particular command from history, consult the documentation for your shell and consider how history is stored. Be careful when editing or deleting history: it is a separate operation from clearing the screen and may not remove copies held by logs, other sessions, or monitoring tools.
Common Problems When Clearing a Terminal
-
The command is not recognized: Confirm which shell or console you are using. Try
clearon macOS or Linux,clsin Command Prompt, orClear-Hostin PowerShell. - The screen clears but old text returns when scrolling: The terminal app may retain scrollback. Use its separate clear-scrollback option.
- The screen immediately fills again: A running program may still be printing output. Stop it only if it is safe to do so; Ctrl+C may interrupt a foreground process.
-
The display looks corrupted: Try the app’s reset option or, where supported, the
resetcommand. - A shortcut does nothing: Shortcuts vary by shell, terminal app, operating system, and active program. Use the relevant clear command instead.
Also check whether you are typing at a shell prompt. If a full-screen program, text editor, or interactive tool is active, it may handle the keyboard input itself. Exit or return to the prompt when appropriate, then run the clear command.
Which Terminal-Clearing Method Should You Choose?
For a quick cleanup, use the method that matches your environment: clear for most macOS and Linux shells, cls for Windows Command Prompt, and Clear-Host for PowerShell. Use Ctrl+L when it is supported and convenient. If your goal is to remove old lines from the scrollback buffer, use the terminal app’s dedicated option rather than assuming a screen-clear command will do it.
Keep the difference in mind: clearing the display makes the terminal easier to read, but it does not delete command history, erase saved output, stop a running process, or undo earlier actions. Once you know which task you mean, choosing the right command is straightforward.
Conclusion
To clear a terminal, type clear on macOS or Linux, cls in Windows Command Prompt, or Clear-Host in PowerShell. Ctrl+L is a useful shortcut in many terminal environments. If you want to remove older lines from view as well, clear the terminal’s scrollback using the app’s own controls. These steps tidy the display, but they do not erase command history or reverse what a command has done.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.