How to Clear Shell Console

shellterminal

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.

Best Answer

The

reset

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.

Related Question