How Do You See The Time Previous Commands Were Entered On A Linux Server?

Question:  How do you see the exact time when previous commands were entered on a Linux server when you use the "history" command?  

Background:  Linux by default logs the time and day when commands were issued.  (There is a limit to the number of previous commands that stay logged.)  The timestamps by default are not visible.

Solution:  For the session, until you log out, this will work:


If you permanently want to see the timestamps associated with the commands entered even after a reboot, you execute this command once:

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

The above works on RedHat, SUSE, and Ubuntu.

Leave a comment

Your email address will not be published. Required fields are marked *