a historical command
1. Grammar
history [options] [history command save file]
Options:
-c: clear history command
-w: Write the history commands in the cache to the history command save file ~/.bash_histoty
1000 historical commands are saved by default, and can be modified in the environment variable configuration file /etc/profile.
2. History command calling method
![](http://dl2.iteye.com/upload/attachment/0126/7517/af982755-456f-3d84-ac70-6851dbebc50c.png)
3. Command and file completion
In Bash, command and file completion are very convenient and commonly used functions. As long as we press the "Tab" key when entering a command or file, it will be automatically completed.
Two actual combat
[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/