Online Linux Terminal Logo
OnlineLinuxTerminal
System & ProcessesCLI Reference

$history

Display the list of previously executed terminal commands.

Syntax DefinitionPOSIX standard
history [OPTIONS]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `history` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How history Works

`history` shows the shell history list with line numbers. It allows users to review previous commands, audit actions, or re-run previous commands using the `!n` event recall syntax.

Common Flags & Command Options

Flag / OptionDescription
-cClear the history list in the current session.
-d [OFFSET]Delete the history entry at position OFFSET.
[N]List only the last N commands.

Practical Real-World Examples

Example #1View recent command history

Outputs the chronological list of commands executed in the session.

Frequently Asked Questions

How do you quickly re-run the last executed command?

Type `!!` and press Enter to execute the previous command, or `!grep` to re-run the most recent command starting with grep.