Bash的历史命令

一 历史命令
1、语法
history [选项] [历史命令保存文件]
选项:
-c:清空历史命令
-w:把缓存中的历史命令写入历史命令保存文件~/.bash_histoty
历史命令默认保存1000条,可以在环境变量配置文件/etc/profile中进行修改。
2、历史命令调用方式


3、命令与文件补全
在Bash中,命令与文件补全是非常方便与常用的功能,我们只要在输入命令或文件时,按“Tab”键就会自动补全。
二 实战
[root@localhost ~]# history -w
[root@localhost ~]# history
1 cat .bash_history
2 history -w
3 history
[root@localhost ~]# vi /etc/profile
[root@localhost ~]# history
1 cat .bash_history
2 history -w
3 history
4 vi /etc/profile
5 history
[root@localhost ~]# !3
history
1 cat .bash_history
2 history -w
3 history
4 vi /etc/profile
5 history
6 history
[root@localhost ~]# !!
history
1 cat .bash_history
2 history -w
3 history
4 vi /etc/profile
5 history
6 history
[root@localhost ~]# !cat
cat .bash_history
cat .bash_history
history -w
[root@localhost ~]# user
useradd userdel userhelper usermod usernetctl users
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# cd /
bin/ dev/ home/ lib/ media/ mydata/ proc/ run/ srv/ tmp/ var/
boot/ etc/ japan/ lib64/ mnt/ opt/ root/ sbin/ sys/ usr/
[root@localhost ~]# cd /
bin/ dev/ home/ lib/ media/ mydata/ proc/ run/ srv/ tmp/ var/
boot/ etc/ japan/ lib64/ mnt/ opt/ root/ sbin/ sys/ usr/
[root@localhost ~]# cd /usr/
bin/ etc/ games/ include/ lib/ lib64/ libexec/ local/ sbin/ share/ src/ tmp/
[root@localhost ~]# cd /usr/l
lib/ lib64/ libexec/ local/
[root@localhost ~]# cd /usr/l
lib/ lib64/ libexec/ local/
[root@localhost ~]# cd /usr/local/

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...