Display Date and Time for each Command in Bash History in Linux
In this tutorial, How to list command display date and time command previously typed in Bash History. The Bash shell provides the command history. Display Date and Time for each Command in Bash History. The default history command $ history The output terminal as below Set time stamps in bash history Define the environment variable name $ HISTTIMEFORMAT="%d/%m/%y %T " The output as below Or your add ~/.bash_profile file $ echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile $ cd $ source ~/.bash_profile The output terminal as below To retrieve Linux bash command line history $ history The output terminal as below Conclusion Displaying the date and time for each command in Linux Linux can be invaluable for monitoring and debugging purposes. By using the HISTTIMEFORMAT variable, you can easily prepend timestamps to your command history, providing a clear record of when each command was executed. This simple yet powerful feature enhances