Hostxpeed
Login Get Started →
Getting Started

How to Clear Terminal Screen

3 min read
23 views
Jun 10, 2026

Prerequisites

Before clearing your terminal, make sure you have:

  • SSH access to your VPS
  • An active terminal session

Method 1: Using clear Command (Most Common)

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Type:

clear

This clears the screen and puts your cursor at the top.

Method 2: Keyboard Shortcut (Ctrl+L)

Simply press:

Ctrl + L

This works in almost all Linux terminals without typing any command.

Method 3: Using reset Command (Full Reset)

reset

Use this if your terminal is displaying garbage characters or is corrupted.

Method 4: Using printf Command

printf "33c"

This sends the terminal reset escape sequence.

Method 5: Clear and Keep Scrollback Buffer

Most clears remove scrollback. To keep scrollback but clear visible screen:

clear -x

Or:

tput clear

Method 6: Alias for Clear with Confirmation

Add to ~/.bashrc:

alias cls='clear && echo "Screen cleared at $(date)"'

Then reload:

source ~/.bashrc

Now use:

cls

Method 7: Clear Specific Line (Not Whole Screen)

Delete current line from cursor to end:

Ctrl + K

Delete current line from cursor to beginning:

Ctrl + U

Method 8: Clear Entire Scrollback Buffer

For some terminal emulators:

echo -e "33[3J"

Or use terminal-specific shortcuts:

  • GNOME Terminal: Ctrl+Shift+K
  • Konsole: Ctrl+Shift+K
  • iTerm2 (Mac): Cmd+K
  • PuTTY: Ctrl+L then clear

Clear Screen in a Script

#!/bin/bash
clear
echo "Script output after clearing"

Create a Function for Smart Clear

Add to ~/.bashrc:

function smart_clear() {
    if [ -z "$1" ]; then
        clear
    else
        printf "33c"
    fi
}

Use:

smart_clear     # normal clear
smart_clear full # full reset

Why Clear Your Terminal?

  • Remove clutter after long commands
  • Improve readability of new output
  • Start fresh before running important commands
  • Hide sensitive information from previous commands

✅ You can now clear your terminal screen using multiple methods.

Was this article helpful?