Shell and Environment

history

Shows previous shell commands.

history lists commands recorded by your shell, helping you reuse, audit, or learn from past work.

Syntax
history [number]

Arguments explained

  • number limits how many entries are printed in many shells.
  • -c clears history in Bash.

Common examples

Show recent commands
history 20

Displays the last 20 recorded commands.

Search interactively
Press Ctrl+R, then type part of a command

Reverse-searches command history in many shells.

history Command
FieldDetails
Commandhistory
CategoryShell and Environment
Primary useShows previous shell commands.
Syntaxhistory [number]