查询我们曾经下达过的命令呢?就使用 history 啰! [root@www ~]# history [n] [root@www ~]# history [-c] [root@www ~]# history [-raw] histfiles 选项与参数: n :数字,意思是『要列出最近的 n 笔命令行表』的意思! -c :将目前的 shell 中的所有 history 内容全部消除 -a :将目前新增的 history 命令新增入 histfiles 中,若没有加 histfiles , 则默认写入 ~/.bash_history -r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中; -w :将目前的 history 记忆内容写入 histfiles 中! 范例一:列出目前内存内的所有 history 记忆 [root@www ~]# history # 前面省略 1017 man bash 1018 ll 1019 history 1020 history # 列出的信息当中,共分两栏,第一栏为该命令在这个 shell 当中的代码, # 另一个则是命令本身的内容喔!至于会秀出几笔命令记录,则与 HISTSIZE 有关! 范例二:列出目前最近的 3 笔数据 [root@www ~]# history 3 1019 history 1020 history 1021 history 3 范例三:立刻将目前的数据写入 histfile 当中 [root@www ~]# history -w # 在默认的情况下,会将历史纪录写入 ~/.bash_history 当中! [root@www ~]# echo $HISTSIZE 1000