Howto Clear Bash History in Linux

Sometime you need to clear bash history for some reason like privacy or something else. Clearing bash history is pretty simple just run this command in your linux terminal

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
history -c
history -c
history -c

Or

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
rm ~/.bash_history
rm ~/.bash_history
rm ~/.bash_history

Prevent Saving History

You can add the command to your ~/.bash_logout so that history will get cleared everytime you logout from terminal

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
echo 'history -c' >> ~/.bash_logout
echo 'history -c' >> ~/.bash_logout
echo 'history -c' >> ~/.bash_logout

Finding Max History Can Be Stored

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
echo $HISTSIZE
1000
echo $HISTSIZE 1000
echo $HISTSIZE
1000

My history stored in ~/.bash_history file can hold up to 1000 last commands