How to Clear Linux terminal screen?

The Linux terminal is an essential tool for system administration and daily tasks. During extended terminal sessions, the screen can become cluttered with output from various commands, making it difficult to focus on current work. Clearing the terminal screen helps maintain a clean workspace and improves productivity.

Linux provides several methods to clear the terminal screen, each with different behaviors and use cases. Let's explore the most effective approaches.

Using the clear Command

The clear command is the most common method to clear the terminal screen. It removes all visible text and positions the cursor at the top-left corner of the terminal.

$ pwd
/home/groot

$ hostname
workstation

$ clear

The clear command has additional options for specific scenarios:

$ clear -x

The -x option prevents clearing the scrollback buffer, preserving command history that you can still access by scrolling up.

Using the reset Command

The reset command provides a more comprehensive terminal cleanup. It not only clears the screen but also resets the terminal to its default settings, fixing display issues that may have occurred from corrupted output.

$ pwd
/home/groot

$ hostname
workstation

$ reset

Use reset when the terminal display becomes garbled or when programs exit improperly, leaving the terminal in an abnormal state. This command is particularly useful after running programs that modify terminal settings.

Using Console Escape Sequences

Console escape sequences provide direct control over terminal behavior. The ESC c sequence completely clears the screen and resets the terminal state.

$ printf "\033c"

You can also use hexadecimal notation for the same effect:

$ printf "\x1Bc"

These escape sequences work at a lower level than the clear command and are useful in shell scripts or when the terminal is in an unusual state.

Keyboard Shortcuts

Most terminal emulators support the Ctrl+L keyboard shortcut, which has the same effect as typing clear. This is often the fastest method for interactive use.

Comparison of Methods

Method Screen Clear Scrollback Terminal Reset Use Case
clear Yes Cleared No General screen clearing
clear -x Yes Preserved No Keep command history
reset Yes Cleared Yes Fix display problems
printf "\033c" Yes Cleared Partial Script automation
Ctrl+L Yes Cleared No Quick interactive use

Conclusion

Linux offers multiple methods to clear the terminal screen, each suited for different scenarios. The clear command is ideal for routine screen cleaning, while reset solves display corruption issues. Choose the method that best fits your current needs and workflow preferences.

Updated on: 2026-03-17T09:01:38+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements