Skip to content

clear Command: Clearing Your Terminal Screen

Summary

The clear command provides a simple way to clear your terminal screen, providing a fresh and uncluttered workspace.

Introduction

The clear command is a straightforward utility used to clear the terminal screen. It removes all previous commands and their output, leaving you with a clean prompt at the top of the terminal. This is particularly useful when the screen becomes cluttered with output, making it difficult to read or navigate. The clear command is a simple wrapper around the tput clear command on many systems.

Use case and Examples

Basic Usage

clear
This command clears the entire terminal screen, bringing the prompt to the top.

Clearing the Scrollback Buffer (Implementation Dependent)

printf '\033c'
While not the clear command itself, this escape sequence often achieves a more thorough clearing, including the scrollback buffer (implementation dependent). Note that some terminals may not support this fully. It's more a terminal emulator feature than a Linux command. Consider this a bonus tip.

Using with other commands

ls -l && clear
This example shows how to list files and then clear the screen after the output is displayed. This is useful for quickly inspecting results and then removing the clutter.

Commonly used flags

Flag Description Example
(None) The clear command doesn't typically accept any flags. Its functionality is solely to clear the screen. Implementations might vary slightly, but the core function remains the same. clear
reset (As an alternative to clear, not a flag) Resets the terminal completely, clearing the screen and resetting terminal settings. Note that this is not a flag for clear itself, but an entirely separate command. reset


Share on Share on

Comments