Name

history

Synopsis

history [options]

history [lines]

Description

Print a numbered command history, denoting modified commands with a *. Include commands from previous sessions. You may specify how many lines of history to print.

Options

-a [file]

bash maintains a file called .bash_history in the user’s home directory, a record of previous sessions’ commands. Ask bash to append the current session’s commands to .bash_history or to file.

-c

Clear history list: remove all previously entered commands from the list remembered by the shell.

-n [file]

Append to the history list those lines in the .bash_history file or in file that have not yet been included.

-r [file]

Use .bash_history or file as the history list, instead of the working history list.

-s command

Add command to working history list without executing it.

-w [file]

Overwrite .bash_history or file with working history list.

Get Linux in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.