Skip to content

How to add Date and Time to Bash History

In this tutorial, you will learn how to add the date and time to bash history. Sometimes it would be very useful to know when a particular command got executed.

By default, you will get history as shown below without a timestamp for each history entry. You can add the date and time to history entries by following the below steps.

Add timestamps to History entries:

You can set timestamps for each history entry by setting the HISTTIMEFORMAT variable in your .bashrc file.

Let’s append the following line to ~/.bashrc file:

HISTTIMEFORMAT="%h %d %H:%M:%S "

After modifying .bashrc file, execute the following command to apply changes:

Now, when you type history, it will show something like:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments