History command: history, history command history
[Root @ linux ~] # History [n]
[Root @ linux ~] # History [-c]
[Root @ linux ~] # History [-raw] histfiles
Parameters:
N: Number, which indicates "List of the nearest n commands!
-C: removes all history content in the current shell.
-A: adds the newly added history command to histfiles. If histfiles is not added, it is written to ~ by default ~ /. Bash_history
-R: Read the content of histfiles to the history Memory of the current shell;
-W: Write the Current history Memory to histfiles!
Example:
Example 1: List all history memories in the current Memory
[Root @ linux ~] # History
# Omitted earlier
1017 man bash
1018 ll
1019 history
1020 history
# The information listed is divided into two columns. The first column shows the code of this command in this shell,
# The other is the instruction content! As for how many Command records will be displayed, it is related to HISTSIZE!
Example 2: List the latest 3 Documents
[Root @ linux ~] # History 3
1019 history
1020 history
1021 history 3
Example 3: immediately write the current data to histfile
[Root @ linux ~] # History-w
# The historical records are written to ~ by default ~ /. Bash_history!
[Root @ linux ~] # Echo $ HISTSIZE
1000
We can use related functions to execute commands! For example:
[Root @ linux ~] #! Number
[Root @ linux ~] #! Command
[Root @ linux ~] #!!
Parameters:
Number: indicates the number of commands executed;
Command: the nearest command searches for the command starting with "command" and executes the command;
!! : Execute the previous command (equivalent to pressing Enter after pressing the keys)
Example:
[Root @ linux ~] # History
66 man rm
67 alias
68 man history
69 history
[Root @ linux ~] #! 66 <= execute 66th commands
[Root @ linux ~] #!! <= Execute the previous command. In this example, it is! 66
[Root @ linux ~] #! Al <= execute the latest commands starting with al (the first 67th commands listed above)