I wants to check on my linux system when which command was fired - at which date and time.
I fired commands like this:
history 50
It shows me the last 50 commands history, but not with date and time at which it was fired. Does any one knows how to do it?
Users set the HISTTIMEFORMAT variable. Bash uses its value to the format string to show the date/time stamp associated with each history entry displayed by the built-in history command. In other words, when this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.
To enable timestamp in Bash history in Linux, you need to set the HISTTIMEFORMAT environment variable. This variable is used to print the timestamp associated with each displayed history entry. Here, the %F option is used to display the date in YYYY-MM-D D (Year-Month-Date) format.
Regarding this link you can make the first solution provided by krzyk permanent by executing:
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile source ~/.bash_profile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With