Today I’ll tell you a very interesting thing, all of us know about history command in linux, but do you know how to see the history with time. We can use some environment variable, it will show date & time in your history command. Now let’s come to an example:
[root@server1 ~]# export HISTTIMEFORMAT=”%T “
[root@server1 ~]# history
1 18:22:42 ls
2 18:22:48 lshal
3 18:22:58 nmap localhost
4 18:23:18 export HISTTIMEFORMAT=”%T “
5 18:23:22 history
6 18:23:38 export HISTTIMEFORMAT=”%T “
7 18:23:40 history
[root@server1 ~]#
for date use the following:-
[root@server1 ~]# export HISTTIMEFORMAT=”%d/%m/%y %T “
[root@server1 ~]# history
1 25/10/12 18:22:42 ls
2 25/10/12 18:22:48 lshal
3 25/10/12 18:22:58 nmap localhost
4 25/10/12 18:23:18 export HISTTIMEFORMAT=”%T “
5 25/10/12 18:23:22 history
6 25/10/12 18:23:38 export HISTTIMEFORMAT=”%T “
7 25/10/12 18:23:40 history
8 25/10/12 18:29:52 export HISTTIMEFORMAT=”%d/%m/%y %T “
9 25/10/12 18:29:54 history
[root@server1 ~]#
I have not checked in here for a while because I thought it was getting boring, but the last few posts are great quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend