Filed Under: General

Deleting your .bash history after logging out

13 April 2008 No Comment Tags: , ,

The bash_history is a file that saves your command line entries. If you execute any commands via SSH it will save them in the file .bash_history, so that you are able to quickly execute older commands again.

However you can imagine that this is a security risk you can easily avoid by cleaning the history after you logout.

First of all you should locate your bash_history.
Nothing easier than that, simply execute:
“locate bash_history” via SSH and it will show you where it is.
The File “.bash_profile” should be in the same directory.

Now either use a SSH editor like nano to open the file “.bash_profile” or simply open it via WINSCP. This is really a personal taste but I prefer using nano instead of vim because it’s easier to handle. Execute “nano .bash_profile”. If it’s in a subdirectory then you will have to “cd” there.

Now add the following lines at the very end:

export HISTSIZE=100
export HISTFILESIZE=100
unset HISTFILE

You can change “100″ to the number of commands you want to keep while being logged on. If you logout it will “unset” everything and delete your commands.
VoilĂ ! Now it will automatically delete your bash_history if you logout.







Like our posts? Then subscribe via Mail:

Email:  

Similar Posts:

Socialize:

delicious stumbleupon

Leave your response!

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.com.