> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Display time with history command
- URL: https://www.bagz.fr/display-time-with-history-command/
- Published: 2017-04-07T21:09:15.000Z
- Updated: 2017-04-07T21:09:15.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

When you are using the *history* command on a UNIX system, by default, you're only getting an action list with numbers but no date and/or time to complete this history. For that, you have to define an environment variable **HISTTIMEFORMAT** that will describe how you want to display the timestamp for each command.

To display the timestamp temporarily (during session), you can just export the variable before sending the command:

$export HISTTIMEFORMAT="%d/%m/%y %T " ; history  

You will get:

2021 01/04/17 11:54:04 systemctl list-units  
2022 01/04/17 11:54:10 systemctl list-unit-files  
2023 01/04/17 11:54:15 cd /etc/  
2024 01/04/17 11:54:33 ls -lsta  
2025 01/04/17 11:54:33 ps auxw | grep apache  
2026 01/04/17 11:54:35 date  
2027 01/04/17 11:54:35 cd ..  
2028 01/04/17 11:54:37 cd /var/log  
2029 01/04/17 11:54:37 ls -lsta  
2030 01/04/17 11:54:40 cat messages  
2031 01/04/17 15:48:44 history  
2032 01/04/17 15:48:51 export HISTTIMEFORMAT="%d/%m/%y %T " ; history  

If you want to keep that display for a future session, you have to add this variable to your bash profile and reload your profile:

$echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> \~/.bash\_profile  
$source \~/.bash\_profile