- 命令别名设置alias unalias
alias的定义规则与变量定义规则几乎相同,所以只要在alias 加上 {“别名”=‘命令 参数’}。[root@www~]#alias lm='ls -l | more' <==需要查询隐藏文件,并且需要列出一页一页查看,需要用到alias lm = ‘ls -l |more’
同时命令别名的设置还可以替代既有的命令
同时我们也可以使用alias来查看已经有别名的命令实际代表什么命令[root@www~]#alias rm='rm -i' <==那么以后使用rm就是默认使用rm -i
如果想要取消命令别名,就使用unalias
[root@www~]#unalias lm
- 历史命令history
参数 含义 n n是数字,代表列出最近n条命令 -c 将目前shell中所有history内容全部消除 -a 将目前新增的history命令新增如hisfiles中,若没有加hisfiles,则默认写入~/.bash_history -r 将historyfiles内容读到目前这个shell的history中 -w 将目前的history记忆内容写入hisfiles中
history命令不只可以让我查询命令,还可以执行命令[root@www~]#history <==列出目前内存内所有的history记忆 1017 man bash 1018 ll 1019 history <==列出的信息中共分为两栏,第一列为该命令在shell当中的代码
参数 含义 number 执行第几条命令的意思 command 由最近的命令向前搜寻命令串开头为command的那个命令,并且执行 !! 执行上一个命令 [root@www~]#history 66 man rm 67 alias 68 man history 69 history [root@www~]#!66 <==执行第66个命令 [root@www~]#!! <==执行上一个命令 [root@www~]#!al <==执行最近以al为开头的命令
命令别名与历史命令
最新推荐文章于 2024-11-24 17:18:08 发布