clear – clear the terminal screen

clear command
clear command

clear clears the terminal screen, moving the cursor to the top-left corner.

Synopsis

clear

Examples

Clear screen

$ clear

Keyboard shortcut (equivalent)

Press Ctrl + L in most terminals.

Clear and scroll buffer

$ clear -x    # Also clears scrollback (Linux)

# macOS alternative
$ printf '\033[2J\033[3J\033[H'

Alternatives

Using tput

$ tput clear

Using reset (also resets terminal)

$ reset

ANSI escape sequence

$ printf '\033c'
$ echo -e "\033c"

In Scripts

#!/bin/bash
clear
echo "Welcome to My App"

Tips

  • Ctrl+L is faster: Works in bash, zsh, and most shells
  • Scrollback preserved: By default, you can scroll up to see history
  • Use reset for glitches: If terminal is messed up, reset fixes it
  • tmux/screen: May need different handling

See Also

  • reset — Reset terminal to default state

Tutorials