Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

clear

Clean the terminal screen (and, by default, the scrollback buffer).

Niveau
Dagelijks Linux
Groep
Shell en hulp
Root nodig
Nee
Pakket
ncurses

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

clear removes all text from the terminal window and puts the prompt at the top. It sends the right control codes for your terminal type (from the TERM variable).

Ctrl+L does almost the same: it clears the visible screen but usually keeps the scrollback. When the terminal shows strange characters after you printed a binary file, reset is stronger than clear.

Zo schrijf je het

clear [-x] [-T TYPE] [-V]

Opties 3

Meest gebruikt

-x
Do not clear the scrollback buffer (only the visible screen).
-T type
Use this terminal type instead of $TERM.
-V
Show the version.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Clear the screen

    clear

    The prompt moves to the top of the window.

  2. 2Clear the screen with the keyboard

    # press Ctrl+L

    Faster than typing clear. Works in Bash and most programs.

  3. 3Keep the scrollback, clear only the screen

    clear -x

    You can still scroll up to see older output.

  4. 4Clear the screen before a demo or a screen share

    clear && history -c

    Clean screen and no old commands with internal names or tokens.

  5. 5Fix a terminal that prints strange signs

    reset

    reset sets up the terminal again. Use it after you cat a binary file by mistake.

  6. 6Clear the screen at the start of a menu script

    clear; echo "1) status  2) restart  3) logs"; read -p "Choice: " c

    Each time the menu shows, the old output is gone.

  7. 7Refresh a simple status view every 5 seconds

    while true; do clear; date; systemctl is-active httpd sshd; sleep 5; done

    A tiny dashboard. watch does this better: watch -n5 'systemctl is-active httpd sshd'.

  8. 8Clear for another terminal type

    clear -T xterm

    Rarely needed: when $TERM is wrong for the terminal you use.

  9. 9Use the tput way in a portable script

    tput clear

    Same result; tput can also set colors and move the cursor.

  10. 10Clear the screen and the scrollback in a jump host session

    clear && printf '\e[3J'

    Some terminals keep the scrollback; the extra code removes it too. Good after showing secrets.

  11. 11Make an alias that clears and lists

    alias cls='clear; ls -l'

    Personal shortcut; put it in ~/.bashrc.

Let op

  • clear does not remove anything from your shell history or from log files. It only cleans the window.
  • Some terminal programs keep the scrollback even after clear.

Tips om te onthouden

  • Ctrl+L = fast clear. reset = repair a broken terminal.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man clear