在Linux中,曾经运行过的命令可以通过history命令查看

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
1992  ll
1993  cc test.c nvram.c -o test
1994  ll
1995  gdb ./test
1996  ./test
1997  ls
1998  reboot
1999  netstat -tln carter.iask.in
2000  ping carter.iask.in
2001  netstat -tln carter.iask.in
2002  history 
2003  history |grep carter
2004  nmap -o -sV carter.iask.in
2005* ping carter.iask.in
2006  nmap -o -sV www.sina.com.cn
2007  nmap -o -sV carter.iask.in
2008  history 

如果要重复执行上述某个命令,复制/粘贴肯定可以,但还有更快速的方法,输入“!序号”,可以快速执行。

1
2
3
4
5
6
7
 2008  history 
 2009  ls
 2010  touch dks
 2011  ll
 2012  history 
root@taylorwang-debug:~# !2010
touch dks