history

Display or manipulate the shell command history.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

history lists previously executed commands with line numbers. You can re-run commands with !N (by number) or !! (last command). Ctrl+R provides interactive reverse search. HISTSIZE controls in-memory lines; HISTFILESIZE controls the history file.

Common flags
FlagMeaning
-c --clearClear all history (session)
-d --deleteDelete a specific history entry by number
-a --appendAppend session history to history file
-n --read-newRead new lines from history file
Examples
history 50Show last 50 commands · explain & risk-check →
history | grep kubectlSearch history for kubectl commands · explain & risk-check →
!42Re-execute command number 42 · explain & risk-check →
history -d 42Delete command 42 from history · explain & risk-check →
export HISTCONTROL=ignoredups:ignorespaceSkip duplicates and space-prefixed commands · explain & risk-check →
Pro tip

Prefix any command with a space to exclude it from history — useful for commands containing passwords or tokens (requires HISTCONTROL=ignorespace).

Related
alias source grep
Open the full explainer →More in Shell & Scripting

Reference text is hand-written and may be incomplete — check man history for your version. Test destructive commands on a non-production system first.