Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Command History with date and time

Tags:

linux

history

I wants to check on my linux system when which command was fired - at which date and time.

I fired commands like this:

history 50  

It shows me the last 50 commands history, but not with date and time at which it was fired. Does any one knows how to do it?

like image 207
Rushvi Avatar asked Jul 22 '16 12:07

Rushvi


People also ask

How do I search Linux history by date?

Users set the HISTTIMEFORMAT variable. Bash uses its value to the format string to show the date/time stamp associated with each history entry displayed by the built-in history command. In other words, when this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.

How do I see time history in Linux?

To enable timestamp in Bash history in Linux, you need to set the HISTTIMEFORMAT environment variable. This variable is used to print the timestamp associated with each displayed history entry. Here, the %F option is used to display the date in YYYY-MM-D D (Year-Month-Date) format.


1 Answers

Regarding this link you can make the first solution provided by krzyk permanent by executing:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile source ~/.bash_profile 
like image 105
Hossein Vatani Avatar answered Oct 05 '22 11:10

Hossein Vatani