Where Is Shell Command History Stored?
Bash .bash_history and zsh .zsh_history locations on Linux and Mac, plus size controls and clearing.
Last updated
Bash appends commands to .bash_history in your home folder on exit; zsh (the Mac default) uses .zsh_history the same way. History size caps come from HISTSIZE and HISTFILESIZE variables.
Commands with leading spaces skip bash history when HISTCONTROL ignores them. That quirk is also how secrets accidentally persist for years.
Where Linux stores this, by platform
~/.bash_history
zsh users check ~/.zsh_history instead. Running shells hold unwritten history in memory until exit.
~/.zsh_history
Mac default shell since Catalina. Older bash setups still use ~/.bash_history in the same home folder.
Frequently asked questions
How do I clear shell history completely?
Clear the in memory list, then truncate the history file. New logins start fresh after both steps.
Why is a command missing from history?
The shell exited uncleanly, history appending is off, or a leading space excluded it. Check HISTCONTROL and file ownership.
Notice an outdated path? Let us know.