Linux clear Command with Examples
In Linux, clear
is built-in command which is used to clear terminal screen.
This command runs on different distributions of Linux based operating systems like Ubuntu, Fedora, Debian, Kali, Red Hat etc. In this tutorial we will discuss syntax for command echo
with examples.
clear Syntax
The syntax for command clear
is:
clear
clear Examples
Before executing clear
command
$ echo Alex
Alex
$ echo Hello
Hello
$ echo Linux
Linux
$ clear
After executing clear
command
$
clear
Description
In addition to clearing terminal window, clear does following things:
clear
clears your screen if this is possible, including its scrollback buffer.clear
looks in the environment for the terminal type given by the environment variableTERM
, and then in the terminfo databas to determine how to clear the screen.clear
writes to the standard output. You can redirect the standard output to a file (which preventsclear
from actually clearing the screen), and latercat
the file to the screen, clearing it at that point.
For more detail, run man clear
on terminal to get complete information about clear
command.