How to Clear Gnome Terminal History – Command Line Tips

command historyescape-charactersgnome-terminalterminal

When we use clear command or Ctrl+L in terminal, it clears terminal but we can still scroll back to view the last used commands. Is there a way to completely clear the terminal?

Best Answer

You can use tput reset.

Besides reset and tput reset you can use following shell script.

#!/bin/sh
echo -e \\033c

This sends control characters Esc-C to the console which resets the terminal.

Google Keywords: Linux Console Control Sequences

man console_codes says:

The sequence ESC c causes a terminal reset, which is what you want if the screen is all garbled. The oft-advised "echo ^V^O" will only make G0 current, but there is no guarantee that G0 points at table a). In some distributions there is a program reset(1) that just does "echo ^[c". If your terminfo entry for the console is correct (and has an entry rs1=\Ec), then "tput reset" will also work.

Related Question