History command is used to check the history of commands with command number and command but sometime when we need to check the date and time of the command entered then we need to enable timestamps but how :)
#To view the history commands
root@GW:~# history | more
1030 route -n
1031 ifconfig eth7 down
1032 ifconfig eth7 up
The list of history command is found in your home directory with hidden filename .bash_history. Here is the partial view of the file
root@GW:~# cat .bash_history
route -n
ifconfig eth7 down
ifconfig eth7 up
Now enabling timestamps using following command
root@GW:~# export HISTTIMEFORMAT="%F %T "
And here is the output now
root@GW:~# history | more
1030 2014-01-13 13:43:14 route -n
1031 2014-01-13 13:43:14 ifconfig eth7 down
1032 2014-01-13 13:43:14 ifconfig eth7 up
This will temporarily enable timestamps for this sessions To make it permanent, Please do following
root@GW:~# vi ~/.bashrc and enter the following lines @ top
HISTTIMEFORMAT="%F %T "
If you want to disable history command list temporarily then you can set HISTSIZE=0 in terminal and if you want to permanently disable then make HISTSIZE = 0 in .bashrc file.
No comments :
Post a Comment