How to Clear Terminal in Linux: Simple Commands Explained
To clear the terminal screen in Linux, use the
clear command which removes all previous output from view. Alternatively, reset can be used to clear the screen and reinitialize the terminal settings.Syntax
The basic command to clear the terminal is clear. It takes no arguments and simply wipes the visible terminal screen.
The reset command also clears the screen but goes further by reinitializing the terminal, which can fix display issues.
bash
clear reset
Example
This example shows how to use the clear command to clean your terminal screen after running some commands.
bash
echo "Hello, Linux Terminal!" clear echo "Screen cleared above this line."
Output
Screen cleared above this line.
Common Pitfalls
Sometimes users try to clear the screen by printing many blank lines, which is inefficient and does not truly clear the scrollback buffer.
Also, using reset unnecessarily can slow down your workflow because it reinitializes the terminal.
bash
printf '\n%.0s' {1..100} # Inefficient way to clear screen clear # Correct way to clear screen
Quick Reference
- clear: Clears the visible terminal screen.
- reset: Clears screen and resets terminal settings.
- Use
Ctrl+Las a shortcut to clear the screen in most terminals.
Key Takeaways
Use the clear command to quickly wipe the terminal screen.
The reset command clears and reinitializes the terminal if needed.
Avoid printing blank lines to clear the screen; it is inefficient.
Ctrl+L is a handy keyboard shortcut to clear the terminal screen.
Use reset only when terminal display issues occur.