Saturday, May 2, 2009

Filtering What Goes Into Your Shell History


I wrote a post here that has a few techniques for filtering what goes into the shell history. It is unwise to store sensitive or dangerous commands in your history. An example of a sensitive command would be one with an inline password. Executing such a command would store your password in cleartext in your history file. An example of a dangerous command is 'rm -rf' If you were to accidentially execute this by using ctrl-r or ! or !? then you could potentially lose important data or destroy your system. Bash offers configurations that let you ignore commands, including the ability to ignore any command that is prepended with a space. It is handy, especially for anyone who makes good use of their shell's history features. Btw, I know a couple folks out there who use zsh. For you guys, know that zsh offers a subset of the bash functionality (HIST_IGNORE_SPACE) so you should check it out.

No comments: