To check the command run on any terminal the command used is "history"
#history
Sample output
$ history
6 tracerout 10.19.250.181
7 traceroute 10.19.250.181
8 ping 10.220.196.64
9 traceroute [oracle@ITPFEBPAS0816P ~]$ ping 10.220.196.64
10 PING 10.220.196.64 (10.220.196.64) 56(84) bytes of data.
11 10.220.196.6
12 traceroute 10.220.196.64
13 ping 210.31.24
14 ping 10.210.31.24
15 ping 10.210.31.16
16 ping 10.220.196.45
17 ping 10.220.196.14
To repeat the 12 the command
#!12
In the above history is not displaying the time stamp .. To get the time stamp
# HISTTIMEFORMAT="%d/%m/%y %T "
# history
$ history
10 07/09/15 14:16:19 PING 10.220.196.64 (10.220.196.64) 56(84) bytes of data.
11 07/09/15 14:16:19 10.220.196.6
12 07/09/15 14:16:19 traceroute 10.220.196.64
13 07/09/15 14:16:19 ping 210.31.24
14 07/09/15 14:16:19 ping 10.210.31.24
15 07/09/15 14:16:19 ping 10.210.31.16
16 07/09/15 14:16:19 ping 10.220.196.45
17 07/09/15 14:16:19 ping 10.220.196.14
18 07/09/15 14:16:19 traceroute 10.220.196.14
#to make the above commands work permanently
$ ls -lart .bash*
-rw-r--r--. 1 oracle oinstall 124 Jan 27 2011 .bashrc
-rw-r--r--. 1 oracle oinstall 18 Jan 27 2011 .bash_logout
-rw-r--r--. 1 oracle oinstall 828 Feb 25 2015 .bash_profile
-rw-------. 1 oracle oinstall 16837 Sep 2 10:39 .bash_history
#to make the above commands work permanently add the below line to .bash_profile
export HISTTIMEFORMAT="%d/%m/%y %T "
Explanation of commands and switches.
- history – GNU History Library
- HISTIMEFORMAT – Environmental Variable
- %d – Day
- %m – Month
- %y – Year
- %T – Time Stamp
Tags:
Linux