Clear your bash command history

Wipe the current session's history and the saved history file.

Linuxbashprivacysecurityclear-historyHigh risk
Run history -c && rm -f ~/.bash_history to clear both the live list and the stored file.

01Command

Command
$ history -c && rm -f ~/.bash_history

02What it does

~/.bash_history is saved when your shell exits, and it records everything — including passwords you pasted into commands and hosts you connected to. history -c empties the current shell's memory list, while removing the file drops the past record; both together give a clean slate. Note that HISTFILE in zsh is ~/.zsh_history instead.

03Risk

RiskHigh risk
!Warning: This is unrecoverable — you lose your own useful history too; already-open terminals will re-save their own buffer when they exit, so close them without exiting first or clear each one.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • bash(1) — manual page
    Arch Linux · community · 2026-09-17
    Evidence: history -c clears the in-memory history list; the HISTFILE (~/.bash_history) is written when the shell exits, so the file must also be removed.

Last verified: 2026-09-18 · Category: Security & Privacy

06Related solutions