How to Clear Terminal: Commands, Methods, and What Actually Changes
Knowing how to clear your terminal window is one of those small skills that makes a big difference in daily workflow. Whether you're debugging scripts, running server commands, or just keeping your screen readable, a cluttered terminal slows you down. But "clearing" a terminal isn't always one simple thing — and what happens under the hood varies more than most people realize.
What Clearing the Terminal Actually Does
When you clear the terminal, you're removing visible output from the current screen. Most of the time, this means the text scrolls out of view or gets erased from the display buffer — but your command history usually stays intact. You can still press the up arrow to recall previous commands, and in many cases, you can scroll up to see earlier output.
This is different from resetting the terminal, which wipes the display buffer entirely and returns the terminal to a clean initial state. The two actions look similar but behave differently depending on your shell and terminal emulator.
The Most Common Ways to Clear the Terminal
Using the clear Command
The most universal method across macOS, Linux, and most Unix-based systems is simply typing:
clear This works in bash, zsh, fish, and most other common shells. It sends a control sequence to your terminal emulator that pushes existing content up and out of view — but often keeps it accessible by scrolling up.
Using the Keyboard Shortcut
On most systems, Ctrl + L does the same thing as typing clear. It's faster and works in almost every terminal environment without needing to type anything. This is the shortcut most experienced developers use by reflex.
On macOS Terminal and iTerm2, Cmd + K is an alternative that more aggressively clears the scrollback buffer, meaning the previous output is actually gone rather than just scrolled out of view.
Using the reset Command
If your terminal is displaying garbled text, strange characters, or behaving oddly after running certain programs, the clear command might not fix it. In that case:
reset This reinitializes the terminal completely, restoring default settings, clearing the display, and fixing any corrupted state. It's slower than clear because it's doing more work, but it's the right tool when the terminal itself has gotten into a bad state.
Clearing the Scrollback Buffer
Just pushing content off-screen isn't always enough. If you're working with sensitive output or simply want a truly fresh start, you may want to clear the scrollback buffer — the stored history of everything that appeared on screen.
| Method | Clears Screen | Clears Scrollback | Resets Terminal State |
|---|---|---|---|
clear | ✅ | ❌ (usually) | ❌ |
| Ctrl + L | ✅ | ❌ (usually) | ❌ |
| Cmd + K (macOS) | ✅ | ✅ | ❌ |
reset | ✅ | ✅ | ✅ |
clear && printf 'e[3J' | ✅ | ✅ | ❌ |
The command printf 'e[3J' sends a specific ANSI escape sequence that explicitly clears the scrollback buffer. Combined with clear, it gives you a fully blank slate in most terminal emulators without the full overhead of reset.
Clearing the Terminal in Specific Environments 🖥️
Windows Command Prompt (CMD)
The Windows Command Prompt uses a different command entirely:
cls This clears the visible screen. CMD doesn't have a scrollback buffer in the same way Unix terminals do, so cls is generally sufficient.
Windows PowerShell
PowerShell accepts both:
Clear-Host or the alias:
cls Both do the same thing — clear the visible terminal output. PowerShell running inside Windows Terminal gives you more control, including keyboard shortcuts depending on your settings.
Git Bash on Windows
If you're using Git Bash, which emulates a Unix shell on Windows, the clear command and Ctrl + L both work as expected, consistent with Linux/macOS behavior.
VS Code Integrated Terminal
The built-in terminal in Visual Studio Code supports clear and Ctrl + L for most shells. VS Code also has a "Clear Terminal" option in the right-click context menu or through the command palette (Ctrl + Shift + P → "Terminal: Clear").
Variables That Affect How Clearing Works
The behavior of clearing your terminal isn't identical across all setups. A few factors shape the outcome:
Your shell — bash, zsh, fish, and PowerShell each handle clear commands slightly differently, especially around scrollback buffer behavior.
Your terminal emulator — The application actually rendering the terminal (iTerm2, GNOME Terminal, Windows Terminal, Hyper, Alacritty, etc.) controls scrollback behavior. The same command can produce visibly different results depending on which emulator you're using and how it's configured.
Terminal emulator settings — Many emulators let you configure the scrollback buffer size, and some have settings that determine whether clear or Ctrl + L also wipes that buffer.
Operating system — macOS, Linux distributions, and Windows each have default shells and terminal apps with their own defaults baked in.
When Clearing Isn't Enough 🔧
There are situations where clearing the display doesn't solve the underlying issue:
- Frozen terminal sessions — Clearing the screen won't unfreeze a process. You'd need Ctrl + C to interrupt a running process, or Ctrl + Z to suspend it.
- Corrupted terminal output — After running certain interactive programs like
vimorless, if they exit improperly, the terminal may be in a raw mode. Here,resetis the right fix, notclear. - Lingering environment variables or settings — Clearing the screen doesn't affect any variables, paths, or configurations set during the session. Those persist until you close the terminal entirely or explicitly unset them.
The Difference Between Clearing and Starting Fresh
A cleared terminal and a new terminal session are not the same thing. When you open a new terminal tab or window, you get a completely fresh shell process — new environment, no session history in memory, clean state. Clearing only affects what you see.
For most everyday use, the visual clean-up of clear or Ctrl + L is all that's needed. But whether that's true for you depends on what you're actually doing, which shell you're running, which terminal emulator you're in, and whether the scrollback history matters for your workflow.