Is there a way to clear up what is displayed on the shell console (in ubuntu linux) in just a single key or two? When I get flood of lines from grep and that exceeds the height of the window, I want to quickly scroll back to the position where I typed the command after the prompt. I can do so if I had opened a fresh terminal before I type the command, and just go to the initial position. But if keep using the same terminal window, I have to manually find the position. Ctrl+l is not an answer because it just scrolls, and the contents of the terminal remains. I cannot use less because the colored output of grep does not show up in color.

  • I'm mildly confused. Are you looking for something similar to cls in DOS?
    – Iszi
    Mar 31, 2011 at 18:28
  • I am not familiar with DOS, but if that allows you to clear the window and have your scroll bar at the top position, then that is what I want.
    – sawa
    Mar 31, 2011 at 18:31
  • 1
    cls in DOS clears the contents of the console and returns you to a blank screen with a fresh command prompt.
    – Iszi
    Mar 31, 2011 at 19:41
  • @lszi I see. It's the counterpart to 'reset' that Faheem gave?
    – sawa
    Mar 31, 2011 at 19:45
  • 1
    No, clear is the counterpart to cls. reset does more. Both will probably work, but based on your description, reset is overkill.
    – Mikel
    Apr 1, 2011 at 1:56

4 Answers 4




command, which is part of ncurses, and is located in the ncurses-bin package on Debian, will completely clear the console. Is that what you want?

Brief summary of reset from the man page:

reset sets cooked and echo modes, turns off cbreak and raw modes, turns on new-line translation and resets any unset special characters to their default values before doing terminal initialization the same way as tset.

As discussed in https://superuser.com/questions/122911/bash-reset-and-clear-commands, and as pointed out by Erik in Shell console clearing, clear will just clear the screen, reset will (as bignose put it), "reset your terminal when it gets messed up by control sequences". Personally, I'm good at messing up my terminal, and when I clear it, I'm not looking to get anything back that was there before, so I just use reset. But ymmv.

  • How is that different to Ctrl+L for the purposes of this question? The user didn't mention terminal corruption, and otherwise it's equivalent as far as I can see.
    – Mikel
    Apr 1, 2011 at 0:17
  • @Mikel I tried Ctrl+L but it did not clear the terminal.
    – sawa
    Apr 1, 2011 at 1:10

I usually just use:


From the clear man page:

clear clears your screen if this is possible.  It looks in the environ-
ment for the terminal type and then in the terminfo database to  figure
out how to clear the screen.

clear ignores any command-line parameters that may be present.
  • 1
    I tried it, but it does not clear the terminal.
    – sawa
    Apr 1, 2011 at 1:10
  • @sawa: Can you provide a screenshot? I still can't understand from your question why clear or Ctrl+L don't work.
    – Mikel
    Apr 1, 2011 at 1:58
  • 3
    @Mikel It just doesn't work. The line is scrolled up, and the cursor is at the first visible line, but the the scroll bar is positioned at the bottom.
    – sawa
    Apr 1, 2011 at 2:04
  • 1
    @sawa: Ah, I see what you mean! I was using PuTTY, and it was the same, but in Gnome Terminal there is a difference. Thanks for explaining.
    – Mikel
    Apr 1, 2011 at 2:10

It's not an answer to your question, but you can use less, and maintain your color see: https://serverfault.com/questions/26509/colors-in-bash-after-piping-through-less


$ grep --color=always foo bar.txt | less -r

You can try this command:

tput reset

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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