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.
As you can see by default you won’t see any timestamp in history command.
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.
We can use a shell variable for this HISTTIMEFORMAT and run the below command. you check whether it’s working.
HISTTIMEFORMAT= ‘%d/%m/%y %T’
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
if you require to apply for all the users, simply add these lines in /etc/profile.
And finally, run source /etc/profile
Successfully tested with user ‘test’ so
You’re done show time in history check time of command enable timestamp in linux timestamp with history