10. History
You can view the command history, and each command will have a serial number marked in front of it.
10.1.1 Command syntax:
History [Options]
10.1.2 option Parameters
History command option parameter meaning
Option option meaning
-C Purge Command history
-W Let Bash immediately write the history command from memory to the. bash_history file
-A writes the currently added history command to the. bash_history file
n Displays the last n command history, n represents the number
-R reads the contents of the history file and takes them as the current history
10.1.2 Call History Command
Example 1, listing all history records in memory
[Email protected]~] #history
# front omitted
1017 Man Bash
1018 LL
1019 History
1020 History
The information listed is divided into two columns, the first column is the code of the command in this shell, and the other is the contents of the command itself! As to how many command records will be displayed, it is related to Histsize!
Example 2, listing the most recent 3 data
[[email protected]localhost~] #history 3
1019 History
1020 History
1021 History 3
Example 3, immediately write the current data to Histfile
[[email protected]localhost~] #history-W
# in the default case, the history will be written to ~/.bash_history!
[[email protected]localhost~] #echo $HISTSIZE
1000
"Linux command in detail" 10, View History command-[historical]