Linux, bash. Command history with timestamps. How to see when a command was executed in bash history.

MarGib June 13, 2026
🌐 🇵🇱 Polski · 🇬🇧 EN
If you use the terminal on Linux systems, you surely know why and what the "history" command is for. It is used to record commands entered in the terminal so that you can later see what was executed or re-run a specific command without having to type it again (especially if it is long). But what if we want to know when a specific command was executed? How can we extract commands executed on a specific day from the command history? One way to find out when commands stored in the history were executed is to apply a specific format to the command history. We set this format as follows: 


export HISTTIMEFORMAT='%F %T '

If we execute the above command in the current session, we can then check the history of issued commands, and we will see not only the commands themselves but also the dates and times when they were used. 

To ensure the history with timestamps is available every time you log into the terminal, you should save this export in the .bash_profile file in the user's home directory.

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

In the entry above for .bash_profile, different date formatting switches were used, however, the effect remains similar; the difference lies in the formatting. 

%d - day

%m - month 

%y - year 



Facebook X E-mail

Comments

Dodaj komentarz

Explore

Blog archive

Table of contents