If you wish to not leave traces of your CLI activity in the .bash_history file, you can exclude the logging of certain commands by appending a space character before them. For example, press the space bar before you type cat /etc/passwd:
<space>cat /etc/passwd
this does not work
put this in .bash_logout
history -c
If you’ve already done everything you want to and you don’t want to save your history, you can also type:
kill -9 $$
to kill bash, and it won’t save any history from that login session.
so the space prefix preventing the saving of the line only works if you enable ‘ignorespace’ option in the HISTCONTROL environmental variable for the bash shell. check out the man page for bash.
That’s a tweak in .bash_history and you may have to remember inserting every time if you dont want list of commands listed out in the history later.
Easiest way is to run “history -r” after you are done, as it will erase your current session history.
“history -c” would erase entire history which is not required in case you only want to clean your own footsteps.
unset HISTFILE
will not save history of the current session after exiting the session. After logging in again, everything comes back to normal.