We all know what the Bash history. Many times we need for some reason (security, paranoia, etc.) that a certain command is NOT saved in the history, that is, and for example, we want all commands to be saved except those related to ssh, in this way if someone manages to access our computer will not be able to know to which computer we do SSH.
To exclude everything related to the command ssh we write the following line in .bashrc :
HISTIGNORE='ere*:ssh*'
In this way if for example we do something like:
ssh root@virtue
... will not have been saved in the history 😉
If we want it to exclude everything related to the command ls we write the following:
HISTIGNORE='ere*:ls*'
Remember that the file .bashrc has a period at the beginning of the name, which means that it is a hidden file that is in our home. If you wish, using the echo command you can write directly in .bashrc without having to open it, for example, let's exclude everything related to ssh from the history:
echo "HISTIGNORE='ere*:ssh*'" >> $HOME/.bashrc
Well I think there is nothing more to add.
regards
This almost inspires me to open a man page and post on this site, writing about how to list hidden files should be a huge contribution.
Interesting tool. The ere it represents?
Interesting 😀 to the bookmarks without in the future I need it, thank you very much.
Really interesting and useful, especially for those of us in the world of network administration (paranoia never hurts).
And there is the pragmatic mode, just type a space before the command and that's it, it won't be remembered.
Well, I always use history -c, but there is nothing left xD, that option is very simple and selective.
The space thing didn't work for me.
Neither do I, that's why I didn't put it in the post from the beginning 🙁
adding:
HISTCONTROL = ignorespace
the space works 🙂
The space thing has worked for me for months configuring this way:
HISTIGNORE = '(space) + (*)' => like this: HISTIGNORE = '*'
😉
Interesting Gaara. Although I don't need it at the moment, I like to know that I have a whole repository of tips here at DesdeLinux.
Short, concise and useful! excellent contribution.