Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux history command

Show commands recorded by your shell in the current history list.

Shell builtin

Syntax

Command form
history [N] | history [-c] | history [-d OFFSET]

Common options

6 options
OptionWhat it does
NShow the most recent N history entries.
-cClear the in-memory history list.
-d OFFSETDelete the history entry at OFFSET.
-aAppend new entries from this session to the history file.
-rRead the history file and append its contents to the list.
-wWrite the current list to the history file.

Usage examples

3 examples

Show commands recorded by your shell in the current history list.

history | tail -n 15

Show the most recent 20 commands.

history 20

Show the last ten displayed history lines.

history | tail -n 10

Notes

history is a shell builtin. Clearing the current list does not always remove history already written to disk.