3

I know that using the history command I can view my past commands, but:

  • Is there a way to view the date and time of the execution of those commands?
  • Or is that kind of information not saved?
  • And if that sort of information is not saved, is there any way to make it so that it does save it so that I can view it later?
Maythux
  • 84,289

1 Answers1

5

Try to run this command from terminal:

HISTTIMEFORMAT="%d/%m/%y %T "

Then now run history:

history

sample output:

 2000  10/06/15 15:49:29 pal -d
 2001  10/06/15 15:49:33 pal -d 10
 2002  10/06/15 15:49:49 pal -d 04 Jul 2015
 2003  10/06/15 15:50:36 gedit/home/maythux/.pal/pal.conf
 2004  10/06/15 15:50:40 gedit /home/maythux/.pal/pal.conf
 2005  10/06/15 15:53:30 cal
 2006  10/06/15 15:53:31 gcal
 2007  10/06/15 15:53:34 sudo apt-get install gcal
 2008  10/06/15 15:53:54 gcal
 2009  10/06/15 15:53:57 man gcal
 2010  10/06/15 15:54:03 pal
 2011  10/06/15 15:55:35 pal -m
 2012  10/06/15 15:56:56 history 
 2013  10/06/15 15:57:39 HISTTIMEFORMAT="%d/%m/%y %T "
 2014  10/06/15 15:57:45 history

To make this permanent add to your .bashrc:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc

Then source your bashrc:

source .bashrc

Now the sample output will be available whenever you run the command history

Maythux
  • 84,289