Adding the time stamp to the History Command

The History command does not output the time stamp with the log of the most recently executed commands.

To Display Date and Time:

To do so, run the following command in the terminal:

Please note that there is a space before the last double-quotes.

If you want to permanently append this changes, add the following line to the ~/.bashrc file:


Run the command, it will be adding ~/.bashrc file

Then, from the terminal, run the following:

Now, to see history, type:

Sample outputs:

To Display dd-MON-YY & AM/PM & Timezone:

Sample Outputs:

Here’s an explanation of the commands and switches:

historyGNU History Library
HISTTIMEFORMATEnvironmental Variable
%dThe day of the month as a decimal number (range 01 to 31)
%mThe month as a decimal number (range 01 to 12)
%yThe year as a decimal number without a century (range 00 to 99)
%TThe time in 24-hour notation (%H:%M:%S)
%rThe time in a.m. or p.m. notation. In the POSIX locale, this is equivalent to %I:%M:%S %p
%ZThe timezone name or abbreviation
sourceIn short, send the contents of the file to the shell
.bashrcIs a shell script that BASH runs whenever it is started interactively


For more info type the following commands:

Vijayan J

Thanks for stopping by guys! I'm Vijayan and Techpulse is my beloved brainchild. Currently working as a PHP developer in a digital marketing start-up, I'm overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across... 'What separates successful people from unsuccessful people is the former's ability to execute'. Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!