By default, history
will only give an event designator and command line entry. Unless the event reference is absolute, the events are relative to the current position in the history list.
history
1995 ls S*.pdf
1996 ls -lh S*.pdf
1997 xdg-open System_01Jun2018_30Jun2018_0133*.pdf
1998 ssh matthew@localhost
1999 gpass
2000 history
To get the date and time, use the HISTTIMEFORMAT
environment variable:
# Display date and time once
HISTTIMEFORMAT="%d/%m/%y %T " history
# Display date and time in this shell
export HISTTIMEFORMAT="%d/%m/%y %T "
history
# Permanently display date and time
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
source ~/.bashrc
history
Now history
will also display the time and date of the event.
history
1995 11/03/10 04:31:36 ls S*.pdf
1996 11/03/10 04:31:38 ls -lh S*.pdf
1997 11/03/10 04:31:40 xdg-open System_01Jun2018_30Jun2018_0133*.pdf
1998 11/03/10 04:31:55 ssh matthew@localhost
1999 11/03/10 04:33:15 gpass
2000 11/03/10 04:33:32 history