Is there any way I can see at what time the commands were executed from the bash history? We can see the order but is there any way I can get the time also?

Bottom-Line: Execution time in the Bash history

  • 6
    I'm amazed how poorly documented this is both on Linux and BSD in the manpages. – Sridhar-Sarnobat Aug 30 '16 at 21:52
  • Check this blog out - sanctum.geek.nz/arabesque/better-bash-history . – dog0 Feb 22 '18 at 10:31
  • 2
    if you're using zsh: history -E – Vahid Nov 6 '18 at 16:58
  • 1
    Not sure why two answers below feel the need to tell you how to open a terminal.. – mwfearnley Dec 24 '18 at 8:39
  • 2
    According to the blog referenced by @dog0 , timestampse apparently do not get saved unless the HISTTIMEFORMAT variable was set when commands were issued. In other words, if you didn't have it set, setting it now will not help you retrieve timestamps of previously issued commands. – Tomislav Nakic-Alfirevic Jan 17 at 15:14

Press Ctrl+Alt+T to open Terminal, then run the command below:


Or, to make the change permanent for the current user:

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



For more info see man bash or An A-Z Index of the Bash command line for Linux.

For commands that were run before HISTTIMEFORMAT was set, the current time will be saved as the timestamp. Commands run after HISTTIMEFORMAT was set will have the proper timestamp saved.

  • 6
    Why declare it with export in .bash_profile? It is a variable only read by bash, not by commands launched from it, so it should not be exported. – Alvaro Gutierrez Perez Oct 19 '15 at 21:36
  • 64
    Note that this will only record timestamps for new history items, after HISTTIMEFORMAT is set for sessions, i.e. you can't use this retrospectively. Some answers here give the impression the history command immediately shows timestamped entries – Louis Maddox Feb 20 '16 at 20:58
  • 7
    @Louis - Actually this worked for me retroactively for me?!?! – stephenmm Mar 29 '16 at 15:24
  • 13
    @Jamil: for people who follow ISO standards, it's "%y-%m-%d" for the date part ;) – Gauthier Mar 31 '16 at 11:03
  • 7
    @Gauthier - actually, just use %F for ISO date ;-) man7.org/linux/man-pages/man3/strftime.3.html – brianmearns Jul 11 '18 at 19:34

Open terminalCtrl+Alt+T and run,




To make the changes permanent follow the below steps,

gedit ~/.bashrc

you need to add the below line to .bashrc file and then save it,

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

run the below command to source .bashrc file,

source ~/.bashrc

After that run history command.

enter image description here


  • Thanks for answering , \will it be permanent change ? – rɑːdʒɑ Dec 15 '13 at 12:06
  • 1
    Hey, I'm doing this in OS X and Windows (through MINGW), and I'm adding it into .bash_profile, what's the diff between profile and rc? – LasagnaAndroid Oct 1 '15 at 17:28

Yes, you can: if you set $HISTTIMEFORMAT, the .bash-history will be properly timestamped. That doesn't help with existing .bash-history content, but will help in the future.

  • 1
    can you expand it for more clarity ? – rɑːdʒɑ Dec 15 '13 at 12:06
  • 3
    Correction to previous post: Setting HISTTIMEFORMAT enables the display of the timestamps...even existing. My favorite is:HISTTIMEFORMAT='%F %T ' as it matters not from which country you reside...everyone knows immediately what time it is. :) – user491029 Jan 8 '16 at 22:43
  • 3
    I set $HISTTIMEFORMAT and I got the times for today even before the commands of this set. – Yasin Okumuş Sep 18 '17 at 13:40

To enable history timestamps for all users, create a script in /etc/profile.d :

echo 'HISTTIMEFORMAT="%Y%m%d %T "' >> /etc/profile.d/timestamp.sh
  • 1
    This will likely not work for users logging in via the GUI, since the default terminal will not run login shells. /etc/bash.bashrc would be a better place. – muru Feb 22 '18 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.