How to use the history command in Linux


The history command works with the command history list. When the command is issued with no options, it prints the history list.

The History library provides a history expansion feature that is similar to the history expansion provided by `csh'. This section describes the syntax used to manipulate the history information.

grep --help
info history
man history
826  ll
827  mkdir software

To see a certain number of commands, you can pass a number to history on the command line.

10 commands
history 10
history | tail -n 10
Repeating Commands
the last command
the last command that started with cd
history | grep aliases
Deleting Commands
history -d 83
history -d 22 32
history -d -5
897  history 10

The syntax for the history command is as follows:

  history [-c] [-d offset] [n] 
  history -awrn [filename]
  history -ps arg [arg...]

Remove history entry at offset which from the history.
Clearing the History List

Related Tags