Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 43 down vote accepted

You can use tput reset.

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

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.

share|improve this answer
+1 from me, Sachin :-) – Nikhil Mulley Jan 7 '12 at 17:38

You can use the reset command, that will reset the terminal settings.

share|improve this answer

I know you're on a gnome terminal, but I thought I'd answer with a tip for others who might be (like me) on a Mac:

If you're using Terminal.app or iTerm.app then Control+L will scroll up so the terminal looks blank, but Cmd+K will actually reset the terminal / clear scroll-back.

Or, if you're able to set keyboard preferences for your terminal you may be able to assign something like Ctrl+K to input echo -e \\033c as was mentioned above.

share|improve this answer
Cmd+K is all i wanted. ty – Err Hunter Mar 30 at 11:13

Anthon's answer works in KDE Konsole, but not urxvt. In urxvt, I've been using reset for a few years to clear the scrollback (along with all the other things it does), and wasn't satisfied that it didn't work in Konsole. So now for Linux I have a new alias:

alias allclear='clear; echo -e "\033c\e[3J"'

But it doesn't work on OS X.

tput reset doesn't work in any context AFAICT.

In KDE Konsole, ctrl-shift-k clears the scrollback (including the current shell prompt, so it's completely empty). In iTerm or Apple's terminal on OS X, cmd-shift-k also clears scrollback. To add this feature to urxvt, add this to ~/.Xresources:

urxvt*keysym.C-S-K: command:\033c
share|improve this answer

I found this on the net years ago, and works well for me. It completely clears the terminal with no scroll history.

echo -e "\e[3J"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.