Clear your bash command history
Wipe the current session's history and the saved history file.
01Command
$ history -c && rm -f ~/.bash_history02What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- bash(1) — manual pageEvidence: 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
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Add a UFW rule to permit inbound traffic on a TCP or UDP port, such as SSH on port 22.