We are aware that the Linux O.s saves whatever
commands we executed and they can be seen by issuing a history command. Linux
also provides a way to search through the history using “fc” command. FC stands
for “find Command” or “fix Command”.
If you need
to find the last l0 commands executed use,
[root@vx111a
bin]# fc -l 10
1000 poweroff
1001 clear
1002 ./catalina.sh start
1003 ps ux
1004 taskset -p 4728
1005 clear
1006 ps ux
1007 kill -9 4728
1008 clear
1009 clear
1010 clear
In order to
show commands between 1000 and 1010
[root@vx111a
bin]# fc -l 1000 1010
1000 poweroff
1001 clear
1002 ./catalina.sh start
1003 ps ux
1004 taskset -p 4728
1005 clear
1006 ps ux
1007 kill -9 4728
1008 clear
1009 clear
1010 clear
To List all
Commands Since the last command beginning with "cat"
[root@vx111a
bin]# fc -l cat
1122 cat /etc/fstab
1123 mount
1124 lsof | grep /soa
1125 clear
1126 fuser -mu /soa
1127 mount
1128 man fuser
1129 man fuser
1130 clear
1131 clear
1132 cd /soa/tomcat/
1133 cd bin/
1134 lsof catalina.sh
1135 lsof catalina.sh start
1136 clear
FC command
allows us to edit using an editor
fc -e vi 1000
1010
This
command allows us to edit the commands between 1000 and 1010 in a vi editor
Happy
Learning J