命令别名与历史命令
命令别名配置: alias, unalias
[root@www ~]# alias // 查看所有的别名
[root@www ~]# alias rm='rm -i' // 设置一个别名
[root@www ~]# unalias lm // 取消一个别名
历史命令: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 中!
使用范例
[root@www ~]# !number
[root@www ~]# !command
[root@www ~]# !!
选项与参数:
number :运行第几笔命令的意思;
command :由最近的命令向前搜寻『命令串开头为 command』的那个命令,并运行;
!! :就是运行上一个命令(相当于按↑按键后,按 Enter)
[root@www ~]# history
66 man rm
67 alias
68 man history
69 history
[root@www ~]# !66 <==运行第 66 笔命令
[root@www ~]# !! <==运行上一个命令,本例中亦即 !66
[root@www ~]# !al <==运行最近以 al 为开头的命令(上头列出的第 67 个)