history

History #

Scroll up and down through the command line history by pressing the up and down arrow.

By default, most Linux systems let you scroll up through 500 prior commands.

This default can be modified.

View the history #

history | less

Search the history #

See grep.

history | grep <some regex>

Search the history incrementally #

History can also be searched incrementally by first hitting ctrl+r, then starting typing – this will cause the search to start going through the history based on the typed characters. Once found, hit enter to execute or ctrl+j to copy.

Reference history #

Once you look through your history an find the line you’re looking for, you can repeat it by using:

$ !<line number>

Rather than referencing a line number, you can also reference based on string matching, which matches the most recent matching string (I don’t do this too often, but it’s available):

$ !<string pattern>