The fastest way to clear your terminal
Type clear and press Enter. That is the command that removes all the text from your terminal window and gives you a blank screen to work with. On Windows PowerShell, type cls instead.
The command does not delete anything from your computer. It only removes what you see on the screen right now. All the files you worked with, all the commands you ran — they are still there. The terminal just scrolls the old text out of view so you can focus on what comes next.
If you want to scroll back up and see what you typed before, you can usually do that by holding Shift and scrolling your mouse wheel up, or by pressing Page Up on your keyboard. The text is still in the terminal's memory.
Key Takeaways
- The clear command (or cls on Windows PowerShell) removes text from your screen but does not delete files or undo commands.
- You can scroll back up to see previous commands even after clearing the screen, because the terminal keeps a history buffer.
- Clearing the screen is useful when your terminal gets crowded and you want to focus on new work without distraction.
- If you want to permanently delete your command history, you need a separate command like history -c on Mac and Linux.
When to clear your screen versus when to clear your history
Clearing the screen and clearing the history are two different things, and which one you need depends on what you are trying to do.
Clear the screen when your terminal is full of old commands and output and you want a fresh workspace. This is purely visual — it makes the window easier to read. Use clear (Mac and Linux) or cls (Windows PowerShell).
Clear the history when you want to remove the record of commands you have typed. This is useful if you typed a password by accident, or if you are sharing your computer and do not want someone else to see what you ran. On Mac and Linux, type history -c to clear the current session, or history -w to clear and save that change permanently. On Windows PowerShell, type Remove-Item (Get-PSReadlineOption).HistorySavePath.
Most people only need to clear the screen. Clearing the history is less common and usually only matters if you typed something sensitive or if you are concerned about what someone else might see if they use your computer later.
How to clear the screen on Mac and Linux
Open your terminal and type clear, then press Enter. The screen goes blank except for the command prompt at the bottom.
You can also use the keyboard shortcut Ctrl+L (hold Control and press L). This does the same thing as typing clear and is faster if you use it often.
If you want to clear the screen and also clear the scrollback buffer (so you cannot scroll up to see old commands), type clear -x instead. This is rarely necessary, but it exists if you need it.
How to clear the screen on Windows PowerShell
Type cls and press Enter. This is the Windows equivalent of the clear command on Mac and Linux.
You can also use Ctrl+L on Windows PowerShell if you have a recent version (PowerShell 7 or newer). On older versions of PowerShell, Ctrl+L does not work, so stick with cls.
If you are using the older Command Prompt (cmd.exe) instead of PowerShell, cls still works the same way.
How to clear your command history permanently
If you typed a password, a private key, or other sensitive information into your terminal by accident, you may want to remove it from the history so it cannot be recovered later.
On Mac and Linux, type history -c to clear the history for your current session only. If you close the terminal without running another command, the history will be restored when you open a new terminal. To make the deletion permanent, type history -w after history -c. This writes the cleared history to disk.
On Windows PowerShell, type Remove-Item (Get-PSReadlineOption).HistorySavePath. This deletes the history file entirely. The next time you open PowerShell, it will start with a blank history.
If you only want to delete a single line from your history instead of the whole thing, that is more complicated and depends on which shell you are using. For most people, clearing the entire history is simpler and safer.
Why your terminal keeps a history and how to use it
Your terminal remembers the commands you have typed so you do not have to type them again. You can press the Up arrow key to go back through your previous commands one at a time. Press Down arrow to move forward through the list.
If you remember part of a command but not all of it, you can type the first few letters and then press Ctrl+R (on Mac and Linux) or Ctrl+F (on Windows PowerShell). This opens a search box where you can type a word from the command you are looking for. The terminal will find and show you matching commands from your history.
This history is stored in a file on your computer. On Mac and Linux, it is usually in a hidden file called .bash_history or .zsh_history in your home directory. On Windows PowerShell, it is stored in a file that PowerShell manages automatically. You do not need to know where these files are unless you are trying to delete them.
What happens to your files when you clear the terminal
Clearing the terminal does not touch any of your files. It does not delete documents, photos, code, or anything else on your computer. It only removes the text that is currently visible in the terminal window.
If you ran a command that deleted a file (like rm filename), clearing the terminal does not undo that deletion. The file is already gone. Clearing the screen just hides the evidence that you ran the command — it does not reverse what the command did.
This is why it is important to be careful with destructive commands like rm (remove) or rmdir (remove directory). Once you run them, the files are gone. Clearing the screen afterward will not bring them back.
Frequently Asked Questions
Does clear delete my files or undo commands I ran?
No. The clear command only removes text from your screen. All your files remain unchanged, and all the commands you ran still took effect. If you deleted something with rm, it is still deleted even after you clear the screen.
Can I scroll back up after I clear the terminal?
Yes, on most terminals. Use Shift+scroll wheel or Page Up to scroll back through your history. The text stays in memory even after you clear the screen, unless you specifically clear the scrollback buffer with clear -x.
What is the difference between clear and cls?
clear is the command for Mac and Linux. cls is the command for Windows PowerShell and Command Prompt. They do the same thing — they blank out your screen. Use whichever one matches your operating system.
How do I delete a single command from my history instead of all of it?
This varies by shell and is more complex than clearing everything. On most systems, you cannot easily delete individual lines. Your best option is to clear the entire history with history -c and history -w (Mac and Linux) or Remove-Item (Get-PSReadlineOption).HistorySavePath (Windows PowerShell).
Is it safe to clear my terminal history?
Yes. Clearing history only removes the record of commands you typed. It does not affect your files, your system settings, or anything else. The only downside is that you lose the ability to search back through old commands you have run.