1. History: You can view the command Chronicle, and each command will have a serial number marked in front of it.
Grammar:
history[Options]
The meanings of the command options are as follows:
| Options |
Option meaning |
| -C |
Clear command history |
| -W |
Let bash immediately write the history command from memory to the. bash_history file |
| -A |
Writes the current New History command to the. bash_history file |
| N |
Displays the last n command history, and N represents the number |
| -R |
Read the contents of the history file and use them as the current history |
Examples of using command history in Linux systems are as follows:
| Example |
Describe |
| !! |
Run the previous command |
| !6 |
Run a 6th command |
| !8/test |
Run the 8th command and add/test after the command |
| !? Cf? |
Run a command that contains a CF string |
!ls
|
Run the previous LS command (or a history command starting with LS) |
| !ls:s/cf/g |
Run the previous LS command, where CF is replaced with G |
| Fc |
Edit and run the previous history command |
| FC 6 |
Edit and run the 6th history command |
| ^boot^roo^ |
Quick replacement. Run after replacing boot of the last command with root |
| !-5 |
Run the penultimate command of the 5th |
| !$ |
Run the last parameter of the previous command |
Linux Base Command completion