Admin-Ahead Community

Linux => General Linux => Topic started by: lijeshk on November 02, 2013, 01:26:38 pm

Title: How to check command history by Date and Time
Post by: lijeshk on November 02, 2013, 01:26:38 pm

The following command sets the time stamp information associated with each history entry to view the history of the command by date and time:


#HISTTIMEFORMAT="%d/%m/%y %T "

or

#echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile

Where,

%d - Day
%m - Month
%y - Year
%T - Time

Then type history command to view the command history with date and time:

#history

Sample output:

---
 1002  02/11/13 03:43:37 HISTTIMEFORMAT="%d/%m/%y %T "
 1003  02/11/13 03:43:42 pwd
 1004  02/11/13 03:43:48 ls -l
 1005  02/11/13 03:43:56 date
 1006  02/11/13 03:44:13 history
---

 :)