This guide shows you how to clear the terminal screen in Ubuntu and most other Linux distributions. You’ll learn the quick keyboard shortcut, the clear command, how to scroll back, and how to completely reset the terminal when it gets into a weird state. No prior knowledge is needed—just a terminal window open.
What You’ll Need
- A Linux system (Ubuntu, Debian, Fedora, Arch, etc.) with a terminal emulator (GNOME Terminal, Konsole, xterm, or similar).
- Basic familiarity with typing commands in the terminal.
Step-by-Step
- Use the keyboard shortcut (fastest). Press
Ctrl + Lin the terminal. This clears the visible screen, leaving your command prompt at the top. It works in almost every terminal emulator and in the virtual consoles (TTY) as well. - Type the
clearcommand. Typeclearand press Enter. This does the same asCtrl + Lbut is useful when you want to script it or when the shortcut isn’t working. - Use the
resetcommand for a full reset. If the terminal is showing garbled characters, misaligned text, or if a program has messed up the terminal settings, typeresetand press Enter. This reinitializes the terminal and clears the screen completely. It may take a second to respond. - Clear the scrollback buffer too. The
clearcommand andCtrl + Lonly clear the visible screen; the scrollback (history) remains. To clear everything, useclear -x(in most terminals) or pressCtrl + Shift + Kin GNOME Terminal, orCtrl + Shift + Xin Konsole. Alternatively, you can useprintf "\033[2J\033[3J\033[H"to clear the screen, scrollback, and move the cursor home. - Use the terminal’s menu. In most graphical terminals, you can right-click and select “Clear Terminal” or use the Edit menu. This is a convenient mouse-based option.
Common Mistakes
- Typing
clsinstead ofclear.clsis a Windows command; Linux usesclear. - Expecting
clearto clear scrollback. By default, it doesn’t. Useclear -xor the terminal’s shortcut. - Using
resetwhen you only need to clear.resetcan take a moment and may briefly change the terminal settings, which is unnecessary for a simple clear. - Forgetting that
Ctrl + Lworks inside many programs. Inless,vim, and other full-screen apps,Ctrl + Loften refreshes the screen instead of clearing it—which is usually what you want.
Tips
- Create an alias for a full clear: add
alias cls='clear -x'to your~/.bashrcor~/.zshrcto have a single command that clears everything. - If you want to clear the terminal after every command, you can add
clearto yourPS1prompt, but that’s usually annoying—stick to the shortcut. - In SSH sessions,
Ctrl + Lworks the same way, so you can clear the remote terminal without any extra setup. - To clear the terminal in a script, use
clearortput clear. The latter uses the terminfo database and is more portable across older systems.
Troubleshooting
- If
cleardoesn’t work, your terminal may be in a broken state. Tryreset. If that fails, close the terminal window and open a new one. - If
Ctrl + Ldoesn’t clear, your terminal emulator may have remapped the shortcut. Check the terminal’s keyboard shortcuts in its preferences. - If the screen is filled with weird characters, a program may have changed the terminal’s character encoding. Run
resetto restore the default. - If the terminal is completely unresponsive, press
Ctrl + Cto interrupt the current process, then tryclearorreset. If that doesn’t work, you may need to kill the terminal process from another terminal (e.g.,pkill gnome-terminal).
Frequently Asked Questions
What is the difference between clear and reset?
clear only clears the visible screen, leaving the scrollback and terminal settings unchanged. reset reinitializes the terminal entirely, which fixes display glitches but also clears the scrollback and resets settings like line wrapping.
Does Ctrl + L work in all terminals?
Yes, Ctrl + L is a standard control character (form feed) that most terminal emulators interpret as “clear screen.” It works in GNOME Terminal, Konsole, xterm, and even in the Linux virtual consoles.
How do I clear the terminal in a script?
Use the clear command in your script. If you want to clear the scrollback as well, use clear -x (supported in most modern terminals) or send the escape sequence printf "\033[2J\033[3J\033[H".
Why does my terminal show a bunch of numbers and symbols after I run a command?
That usually happens when a program outputs raw escape codes or when the terminal’s character set gets corrupted. Run reset to fix it.
Can I clear the terminal without using the keyboard?
Yes, you can use the terminal’s menu (right-click > Clear Terminal) or type clear and press Enter. Some terminals also have a clear button in the title bar.
Is there a way to clear the terminal after each command automatically?
Yes, you can add clear to your PROMPT_COMMAND variable (in bash) or precmd hook (in zsh), but it’s not recommended because it removes the ability to see previous command output.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Forget a Wi-Fi Network on Mac: Step-by-Step
- How to Prevent Your New iPad From Overheating
- How to Choose Task Management Software
- How to Bypass FRP with PC: Step-by-Step Guide
- Add Music to Video on iPhone: Step-by-Step
- Fix Zoom Lag on Windows 10: 9 Proven Steps