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 22Type:
clearThis clears the screen and puts your cursor at the top.
Method 2: Keyboard Shortcut (Ctrl+L)
Simply press:
Ctrl + LThis works in almost all Linux terminals without typing any command.
Method 3: Using reset Command (Full Reset)
resetUse 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 -xOr:
tput clearMethod 6: Alias for Clear with Confirmation
Add to ~/.bashrc:
alias cls='clear && echo "Screen cleared at $(date)"'Then reload:
source ~/.bashrcNow use:
clsMethod 7: Clear Specific Line (Not Whole Screen)
Delete current line from cursor to end:
Ctrl + KDelete current line from cursor to beginning:
Ctrl + UMethod 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 resetWhy 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.