Thursday, March 17, 2016

History with dates and time

Normally, we type the command for getting the command history in the terminal.

#history

You have to add the following line into the file  ~/.bashrc  to view the history with dates permanently.

export HISTTIMEFORMAT=”%d/ %m/ %y %T “
and then, from terminal run,

#source ~/.bashrc

Explanation of commands and switches.

history – GNU History Library
HISTIMEFORMAT – Environmental Variable
%d – Day
%m – Month
%y – Year
%T – Time Stamp
source – in short send the contents of file to shell
.bashrc – is a shell script that BASH runs whenever it is started interactively.