I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something I typed a month ago, then I started to press all the keys like crazy looking for what could've triggered it. Turns out UPARROW key shows my bash history even after deleting .bash_history.

How can I delete my bash history for real?

  • 8
    .bash_history is overwritten every time you close a bash shell. So if you start bash, delete .bash_history, and log off, you'll have accomplished exactly nothing.
    – Shadur
    Jan 13, 2018 at 14:05
  • 15
    Your cat deserves a huge reward. You've been using bash for how long without discovering it has command-line recall and editing? Do you just retype every command line from scratch every time or something? That would make the shell very unpleasant to use.
    – cas
    Jan 14, 2018 at 3:57
  • @cas ten years. Now that you say it I press Uparrow to repeat commands, but I understood it as kind of a 'short term' memory no more than a few lines long. I wasn't warned that deleting .bash_history won't delete bash history.
    – bunden
    Jan 14, 2018 at 15:31
  • Deleting ~/.bash_history really does delete ~/.bash_history....but (unless you take steps to prevent it, like clearing the in-memory history by running history -c just before you logout or setting HISTFILE=/dev/null or just unseting it) bash will just save its current history again when it exits. BTW, the HISTSIZE env var tells bash how many lines of history to keep in memory, and HISTFILESIZE tells bash the maximum number of history lines to save. both of these can be set in, e.g., your ~/.bashrc. PS: your cat deserves a 2nd reward for teaching you a valuable lesson :)
    – cas
    Jan 14, 2018 at 16:14
  • @cas I think deleting .bash_history should delete bash history. It seems intuitive to me. What it doesn't seem intituive is history -c, history -w, unsetting variables.. that's nuts from the user experience perspective.
    – bunden
    Jan 14, 2018 at 16:51

6 Answers 6


In some cases (some bash versions), doing a:

$ history -c; history -w

Or simply

$ history -cw

Will clear history in memory (up and down arrow will have no commands to list) and then write that to the $HISTFILE file (if the $HISTFILE gets truncated by the running bash instance).

Sometimes bash choose to not truncate the $HISTFILE file even with histappend option unset and $HISFILEZIZE set to 0.

In such cases, the nuke option always works:

history -c; >$HISTFILE

That clear the history list of commands recorded in memory and all commands previously recorded to file. That will ensure that the running shell has no recorded history either in memory or disk, however, other running instances of bash (where history is active) may have a full copy of commands read from $HISTFILE when bash was started (or when a history -r is executed).

If it is also required that nothing else (no new commands) of the present session would be written to the history file, then, unset HISTFILE will prevent any such logging.

  • 1
    Editing HISTFILE and doing history -c && history -r would replace your current history with manually modified history. In some cases, that may be better than throwing all the history away. Apr 9, 2018 at 10:52
  • This (at least history -c) would also need to be run in all active interactive bash shell sessions (if there is more than one), or the other sessions will write their history to $HISTFILE when they exit.
    – Kusalananda
    May 14, 2020 at 7:29
  • @Kusalananda Yes! That is correct.
    – user232326
    May 14, 2020 at 7:40

bash has a session history in memory which is written to file if the shell variable HISTFILE is set to a filename when bash exits.

If you delete the file pointed to by HISTFILE, unset that variable, and exit bash, then that shell session will not leave any persistent history.

Failing to unset the HISTFILE variable but deleting the file would just empty the persistent history, but the current session's history would be saved when the shell exits.

  • 3
    A history -c; history -w will clear both memory and file history. Unsetting HISTFILE is only required if no further commands should be logged to the history (not exactly what was asked IMhO).
    – user232326
    Jan 13, 2018 at 15:20

I had a similar issue and executing the following two commands removed the bash history

  1. $ history -c
  2. $ cat /dev/null > ~/.bash_history

Next, make sure to exit all terminals and start a new terminal, and you should not see any history command when you press the up arrow button.

  • Welcome to the site, and thank you for your contribution. Please note though that this approach was already suggested in this answer; you may want to edit yours to more clearly show the differences in the approach (apart from the ordering, which should not matter that much).
    – AdminBee
    May 14, 2020 at 7:34

"How can I delete my bash history for real?"

Exit bash, start a different shell, delete the bash history file.


logout, log into a different account that has write permission on the history file, delete the history file.


Open your file manager and tick show hidden files. Find .bash_history in your home folder. Open it with your text editor. Delete the file contents. Job done.

  • Linux is not Windows :)
    – GMaster
    May 14, 2020 at 6:02

While leaving the shell, do it all in once, like

echo "" > ~/.bash_history && history -c && exit
  • @roaima, you're apsolutely right, thank you. Corrected.
    – user853069
    Feb 18, 2019 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.