Automatically clear GNU Bourne-Again SHell history when you exit a login shell.
HISTFILE shell variable on login to ensure that the command history will be not saved when a shell exits.
$ echo "unset HISTFILE" | sudo tee /etc/profile.d/unset_histfile.sh
HISTSIZE shell variable to
0 on login, so executed commands will not be saved in the history list.
$ echo "HISTSIZE=0" | sudo tee /etc/profile.d/disable_histsize.sh
/etc/bash.bash_logout login shell cleanup file that will be executed when a login shell exits. Use it to clear history list.
~/.bash_logoutindividual login shell cleanup file.
$ echo "history -c" | sudo tee /etc/bash.bash_logout
HISTFILEshell variable was unset. This also means that history list will be not initialized from the history file on startup.
~/.bash_history history file to keep things clean. Remember about other users.
You can always store history list to a custom file. Notice, it will append current history list to a file.
$ HISTFILE=session_history.txt history -w
$ cat session_history.txt cat .bash_history HISTFILE=session_history.txt history -w
HISTORY section in the
bash manual page to learn more about this topic.