How to set OR enable Timestamp for the previously executed commands in Linux?
Posted by Category: Linux AdministrationLinux provides a command called “history” to view the previously executed commands on shell. By default, the “history” command display only the commands that were executed but not the date and time when they were executed. To display the time OR the date when the previous commands were executed on shell, you need to set the “HISTTIMEFORMAT” variable.
So, in order to check the date and time of previously executed commands in Linux, set the “HISTTIMEFORMAT” variable by executing the command:
# export HISTTIMEFORMAT=”[%F] [%T] “
You can also insert the above line at the end of the .bash_profile file
# vi /root/.bash_profile
Once you save the file, open a new SSH session and execute the ‘history’ command to view the timestamp of the executed commands.
For example:
root@server [~]# history
1068 [2010-08-05] [07:17:04] ps -auxf
1069 [2010-08-05] [07:17:06] top c
1070 [2010-08-05] [07:17:35] ll
1071 [2010-08-05] [07:37:51] ls -la
1072 [2010-08-05] [07:41:37] cat /root/.bash_profile
1073 [2010-08-05] [07:41:47] cd
The commands in the above output is just an example.
Tags: check the date and time of previously executed commands in Linux, check the history of commands executed, history command do not show the time of commands, how to check previously executed commands in linux?, how to check the date and time of previous commands?, how to enable date-time for linux command history?, how to enable timestamp for linux commands?, how to set HISTTIMEFORMAT variable?

November 15th, 2010 at 6:02 pm
this variable give me the next mensage -bash: HISTTIMEFORMAT: readonly variable
November 15th, 2010 at 6:03 pm
i forgot, on slackware 13.0
November 17th, 2010 at 11:49 am
The variable on Slackware may be different. Will email you when I figured it out.