Under Construction

Listing the History

The current history can be listed using “history” (without arguments):

[user01@aixe01 ~]$ history
    1  ls -l
    2  ls -l
    3  hostname
    4  df /
    5  pwd
[user01@aixe01 ~]$

The variable HISTSIZE can be used to configure the maximum number of commands that the history should contain at most.

[user01@aixe01 ~]$ HISTSIZE=2
[user01@aixe01 ~]$

Note: The default value is 500.

After setting the HISTSIZE variable to 2, the internal history list is shortened to just 2 entries. Accordingly, only the last 2 commands are printed:

[user01@aixe01 ~]$ history
    4  pwd
    5  HISTSIZE=2
[user01@aixe01 ~]$

A history list that is too small typically makes no sense, since then, interesting commands disappear from the list too quickly and can therefore no longer be repeated. The default of 500 should work in most cases.

By specifying a number as an option, the number of commands shown is limited to specified number:

[user01@aixe01 ~]$ history 3
    3  hostname
    4  df /
    5  pwd
[user01@aixe01 ~]$

Only the last n (here 3) commands are shown, no matter how long the internal history list is. This is especially useful when the history is very long, but you don’t want to see all entries.