Shell

history

Display or manipulate the command history list.

Synopsis

syntax
history [N]

Examples

Show full command history
history
Show last 20 commands
history 20
Clear command history
history -c
Re-run command number 42
!42
Repeat last command
!!

Common options

FlagDescription
-cClear the history list
-dDelete entry at offset
-wWrite current history to file
-rRead history file into current list

About history

The `history` command display or manipulate the command history list. Shell commands configure your interactive environment — variables, aliases, history, and shell options.

The shell is your primary interface with Linux, and customizing it improves productivity. These commands work across bash, zsh, and other POSIX-compatible shells with minor differences.

The command accepts 4 commonly used flags shown above, though the full set of options is available in the man page (`man history`). The 5 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Shell Commands

Other commands in the Shell category

Related tools