How To Display Timestamp In History Command On Linux

How To Display Timestamp On Linux

The history command is one of the most important in the Linux environment because you can check what commands have been run on the servers. we can enable timestamp and check the time of running commands in Linux with history. You can also show time and how to display the timestamp in history.

It keeps all the tracks of running commands but you might be not seeing any timestamp along with it. you have to set the timestamp in the configuration file.

Check Out: How To Install Winscp Open-source Software In Ubuntu 18.04

As you can see by default you won’t see any timestamp in history command.

how to display timestamp

The value of HISTSIZE variable is used as the number of commands to save in history. If your HISTSIZE is set, the timestamp will be associated with all the history commands.

Check Out: Set Java 8  Environmental Variable Path On Redhat / CentOS 7

We can use a shell variable for this HISTTIMEFORMAT and run the below command. you check whether it’s working.


show time in history

Now you can see it worked and after rebooting, you won’t be seeing timestamp. So, if you want to keep it permanent, so you can follow the below steps. so

You can also use this command export HISTTIMEFORMAT= “%F %T”

To make it permanent on current shell, add above line in vim ~/.bashrc and run source ~/.bashrc

Check Out: Command To Check Swap Partition On Linux Server

if you require to apply for all the users, simply add these lines in /etc/profile.

check time of command

And finally, run source /etc/profile

 enable timestamp in linux

Check Out: Create and Configure Elastic Load Balancer On Amazon Cloud

Successfully tested with user ‘testso

You’re done show time in history check time of command enable timestamp in linux timestamp with history

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment