RJ07 RJ07 - 3 months ago 11x
Linux Question

Linux Command History with date and time

I wants to check on my linux system that when which command was fire with which date and time.

I did fire below command,

history 50

which shows me last 50 commands history but not with date and time it was fired. Does any one knows how to do it?


It depends on the shell (and its configuration) in standard bash only the command is stored without the date and time (check .bash_history if there is any timestamp there).

To have bash store the timestamp you need to set HISTTIMEFORMAT before executing the commands, e.g. in .bashrc or .bash_profile. This will cause bash to store the timestamps in .bash_history (see the entries starting with #).