Bash的历史命令

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


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