How to Clear Bash History At Login

Hello Linux Geeksters.

Watch Free Movies

As you may know, the bash history is stored in ~/.bash_history. And it does not get trown away, unless you do something about it.

I needed to delete my bash history at login and so, I used the easiest method ever possible for doing that. I have just appended this to my ~/.bashrc: rm ~/.bashrc

$ echo 'rm ~/.bash_history' >> ~/.bashrc

It deletes the ~/.bash_history file at startup, so a black history file is created every time.

But, while I was browsing the askubuntu questions for my personal development, I have found this nerdier method for clearing the bash history at login: cat /dev/null > ~/.bash_history && history -c && exit

To append it in your ~/.bashrc do:

$ echo 'cat /dev/null > ~/.bash_history && history -c && exit‘ >> ~/.bashrc

Or, just link /dev/null to ~/.bash_history

$ ln -sf /dev/null ~/.bash_history


Scroll to Top