Menu

Enable timestamp in Linux History command
The Bash history feature is an invaluable tool which allows users to recall commands previously entered into their shell with relative ease. This makes it easy to enter repeated commands and keep track of what was done on a system. By default, however, a user is unable to see whenthese commands were actually entered. When auditing a system, it can sometimes be useful to see this type of information, for example when trying to determine how and when a file may have gone missing on the file system. Since Bash version 3, however, you are able to enable time-stamping of entries for review later.

Applicable versions of Bash provide the environment variable HISTTIMEFORMAT which you can set for this purpose. Although it is empty by default, you can simple assign a time format string to enable time-stamping.
Enable timestamp in bash history
To enable time stamp on your bash history type following command on your terminal:
$ export HISTTIMEFORMAT="%F %T "
Now execute
$ history
It will print the command line history with corresponding timestamp when the command was executed.
$ # history
    1  2016-06-12 15:14:15 nmtui
    2  2016-06-12 15:14:15 ping 8.8.8.8
    3  2016-06-12 15:32:24 export HISTTIMEFORMAT="%F %T "
    4  2016-06-12 15:32:26 history

About Author:


I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Next
Newer Post
Previous
Older Post

0 comments:

Post a Comment

 
Top