# man > clear

> **TLDR:** Clears the screen of the terminal.
>
- Clear the screen:
  `clear`
- Clear the screen but keep the terminal's scrollback buffer (equivalent to pressing `<Ctrl l>` in Bash):
  `clear -x`
- Indicate the type of terminal to clean (defaults to the value of the environment variable `$TERM`):
  `clear -T {{type_of_terminal}}`
- Display the version of `ncurses` used by `clear`:
  `clear -V`

*Source: tldr-pages*

---

[_clear_(1)](https://www.chedong.com/phpMan.php/man/clear/1/markdown)                                    User commands                                   [_clear_(1)](https://www.chedong.com/phpMan.php/man/clear/1/markdown)

## NAME
       **clear **- clear the terminal screen

## SYNOPSIS
       **clear **[**-x**] [**-T _**terminal-type_]

### clear -V

## DESCRIPTION
       **clear  **clears  your terminal's screen and its scrollback buffer, if any.  **clear **retrieves the
       terminal type from the environment variable _TERM_, then consults the _terminfo_  terminal  capa‐
       bility database entry for that type to determine how to perform these actions.

       The  capabilities  to  clear the screen and scrollback buffer are named “clear” and “E3”, re‐
       spectively.  The latter is a _user-defined_ _capability_, applying an extension mechanism  intro‐
       duced in _ncurses_ 5.0 (1999).

## OPTIONS
       **clear **recognizes the following options.

### -T _
                necessary, because the terminal type is inferred from the environment variable _TERM_.
                If this option is specified, **clear  **ignores  the  environment  variables  _LINES_  and
                _COLUMNS_ as well.

### -V       
                cessful status.

### -x       

## PORTABILITY
       Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor  X/Open
       Curses Issue 7 documents **clear**.

       The  latter  documents  **tput**,  which could be used to replace this utility either via a shell
       script or by an alias (such as a symbolic link) to run **tput **as **clear**.

## HISTORY
       A **clear **command using the _termcap_ database and library appeared in 2BSD (1979).  Eighth  Edi‐
       tion Unix (1985) later included it.

       The commercial Unix arm of AT&T adapted a different BSD program (**tset**) to make a new command,
       **tput**, and replaced the **clear **program with a shell script that called “**tput clear**”.

           /usr/bin/tput ${1:+-T$1} clear 2> /dev/null
           exit

       In 1989, when Keith Bostic revised the BSD **tput **command to make it similar to AT&T's **tput**, he
       added a **clear **shell script as well.

           exec tput clear

       The remainder of the script in each case is a copyright notice.

       In 1995, _ncurses_'s **clear **began by adapting BSD's original **clear **command to use _terminfo_.  The
       **E3 **extension came later.

       •   In  June  1999, _xterm_ provided an extension to the standard control sequence for clearing
           the screen.  Rather than clearing just the visible part of the screen using

               printf '\033[2J'

           one could clear the scrollback buffer as well by using

               printf '\033[**3**J'

           instead.  “XTerm Control Sequences” documents this feature as originating with _xterm_.

       •   A few other terminal emulators adopted it, such as PuTTY in 2006.

       •   In April 2011, a Red Hat developer submitted a patch to the Linux kernel,  modifying  its
           console  driver  to  do the same thing.  Documentation of this change, appearing in Linux
           3.0, did not mention _xterm_, although that program was cited in the  Red  Hat  bug  report
           (#683733) motivating the feature.

       •   Subsequently,  more  terminal developers adopted the feature.  The next relevant step was
           to change the _ncurses_ **clear **program in 2013 to incorporate this extension.

       •   In 2013, the **E3 **capability was not exercised by “**tput clear**”.   That  oversight  was  ad‐
           dressed in 2016 by reorganizing **tput **to share its logic with **clear **and **tset**.

## SEE ALSO
       [**tput**(1)](https://www.chedong.com/phpMan.php/man/tput/1/markdown), [**xterm**(1)](https://www.chedong.com/phpMan.php/man/xterm/1/markdown), [**terminfo**(5)](https://www.chedong.com/phpMan.php/man/terminfo/5/markdown)

ncurses 6.4                                  2023-12-16                                     [_clear_(1)](https://www.chedong.com/phpMan.php/man/clear/1/markdown)
