With the Linux history command you can display the commands that have been issued.
For example
history |grep route
Displays all the commands (in the history file) containing the word route.
It displays output like
15 traceroute 2001:db8:8::9
16 sudo ip -6 route add fd00::6:1:1/128 dev tap2
18 sudo ip -6 route add 2001:db8:8::9/128 dev tap2
30 grep route /home/zPDT/*.sh
40 ip -6 route
This page has some good examples of history usage
- !?route displays the lines in the history file which include route
- !5 executes the 5th line in the history file
I wanted to find the command I issued yesterday around 4PM. You can display the dates and times of the history records.
Setting the environment variable
HISTTIMEFORMAT="%d/%m/%y %T "
history |grep route
gave me
30 12/02/24 07:58:50 grep route /home/zPDT/*.sh
40 12/02/24 07:58:50 ip -6 route
46 12/02/24 07:58:50 traceroute 2001:db8:8::9
74 12/02/24 07:58:50 traceroute 2001:db8::3
Using
HISTTIMEFORMAT="%T "
history |grep route
gave just the time of day.
30 07:58:50 grep route /home/zPDT/*.sh
40 07:58:50 ip -6 route
46 07:58:50 traceroute 2001:db8:8::9
74 07:58:50 traceroute 2001:db8::3
86 07:58:50 traceroute 192.168.1.74
To keep this, you should put
export HISTTIMEFORMAT=”%T “
in the .bashrc file
You can also set in .bashrc
export HISTSIZE
=50 The maximum number of entries displayed with the history list.export HISTFILESIZE
=5000 The maximum number of entries in the .bash_history file.