Check Linux Terminal History Sorted by Dates

How To Check Linux Command History By Date

Hello guys, In this article, we will be discussing how to check Linux command history sorted by dates. Using the History command, We can check all the previously executed commands in a list. It also stores the date and time of each command but by default, it does not show the date and time. To view the date and time when the commands were executed, Follow this article till the end.

Checking Linux commands by dates using the history command

Open a terminal by pressing Ctrl+Alt+T or through the app drawer. Run the history command to view the command line history:

history
command-history-1

Now, with the export command, change the format of the global variable HISTTIMEFORMAT by running the following command:

export HISTTIMEFORMAT='%F %T'
history
command-history-2

To check the command history of a particular date with grep, execute the following command:

history | grep <yyyy-mm-dd>

Replace the date in the above command with the particular date for which you want to check the history.

history | grep '2022-01-22'
command-history-3

To check commands for multiple dates, enter the following command:

history | grep -E '2022-01-22|2022-01-20|2022-01-17'
command-history-4

Conclusion

So, We learned How to check the Linux command history by date. You can view history for a particular date or even multiple dates. I hope it works for you. Thank you for reading!