Linux: Clear Bash Shell history

Clear content for current and, in some cases, global command shell history can be important for System Administrators.

This procedures are (for example) very useful when some cleat-text password has been passed via command-line and the System Administrator needs to clear them from history.

unset HISTFILE

Disable history for current shell session.

HISTFILE=/dev/null

Disable history for current shell session.

history -c

Clear history for current shell session.

rm ~/.bash_history; ln -s /dev/null ~/.bash_history

Remove your BASH history and then link it to /dev/null.

rm ~/.bash_history && kill -9 $$

Remove .bash_history file and exit from session.


Comments are closed.