Wednesday, October 6, 2010

Shell tip: Clear the command history and screen when you log out

SkyHi @ Wednesday, October 06, 2010
"reset" or "clear" will both clear your terminal. "reset" does a bit

more, such as set it back the way it was when you started, in case

some control characters have changed something. For example if you

run 'cat somefile.jpg", somefile.jpg is not plain text so will probably

mess up your terminal in some way.



If you are using "bash", "history -c" will clear the your command history,

and "history -r" will read it again from the history file. So if you do

"history -c; history -r;" your history will be back to what it was when

you started your terminal session.



Combining all three will pretty much put your teminal back to the way it

was when you opened it. This will not clear any variables you may have

set.



"history -c; history -r; reset;"



If this is something you do frequently, you may want to append a line to

your .bashrc file,



alias histscreenclear="history -c; history -r; reset;"



to condense them into one command.





=======================================================






history -c will clear the entire bash history.

To only clear the current session history use:

history -r.

Kumar Chetan Sharma
November 20, 2008




even after running clear or history -c, which I find is the best
option to add to ./bash_logout, I can still scroll my putty screen and
see what all I have done. Is there any way to completely erase this
information.

Vinnie
July 15, 2009

Kumar asked about clearing the information from his putty window.


To do so -

1. Right click on the top bar of the putty window

2. A Context menu will appear

3. Select “Clear Scrollback”


This will erase all details of your session from putty’s scrollback buffer.







REFERENCES
http://linux.derkeiler.com/Newsgroups/comp.os.linux.misc/2010-01/msg00462.html
http://www.cyberciti.biz/tips/howto-clear-screen-when-you-logout.html