The Linux history command is primarily used to display historical instruction records and to release instructions in the history record.
>history command syntax:
[[Email protected]]# history [n]
[Email protected]]# history [-c]
[Email protected]]# history [-raw] Histfiles
Parameters:
N: number, to list the most recent n-pen commands
-C: Eliminate all history content in the current shell
-A: Add the current New History command to Histfiles, and if there is no histfiles, the default write ~/.bash_history
-r: Read Histfiles's contents into the current Shell's history memory
-W: Writes the current history memory content to Histfiles. Linux system when you enter and execute commands in the shell (console), the shell automatically logs your commands to the history list, which is typically saved in the. bash_history file in the user directory. Save 1000 By default, and you can change this value. If you type history, it will show you the top 1000 historical commands you used, and give them a number, and you'll see a numbered list quickly rolled over the screen. You may not need to see all the items in the 1000 commands, but you can also add numbers to list the most recent n-pen commands. The history command in Linux not only allows us to query historical commands. We can also use the relevant features to help us execute commands. Run a specific historical command history lists all of the history commands that bash has saved and numbers them, and we can run specific historical commands in the same way as the exclamation mark number.
Syntax Description:
[Email protected]]# [!number] [!command] [!]
Parameter description:
Number: The meaning of the first instruction;
Command: The first few letters of the instruction
! : The meaning of the previous instruction!
History Command Combat
1. Out of all the historical records:
[[email protected]] # History
2. Only the last 10 records are listed:
[[email protected]] # History 10 (note, history and 10 have spaces in between)
3. Execute the command using the command record number, and execute the 99th command in the history list
[[email protected]] #!99 (! And 99 no spaces in the middle)
4. Repeat the previous command
[[email protected]] #!!
5. Perform the last command that starts with RPM (!) represents a string, which can be randomly lost, and the shell will search forward from the last history command, and the first matching command will be executed. )
[[email protected]] #!rpm
6. List all history by screen:
[[Email protected]]# History | More
7. Immediately clear history of all current history commands
[[email protected]] #history-C
In addition to using the history command, you can also use the UP and DOWN ARROW keys to scroll through the command past in the shell or GUI terminal prompts, until you find the command you want. This allows us to easily edit one of the preceding commands without having to enter similar commands repeatedly. The use of the history command is really great! But you need to be careful about security! Especially the root history file, this is the hacker's favorite! Because the careless root will be a lot of important information in the process of execution will be recorded in the ~/.bash_history, if the file is parsed, the consequences are unimaginable!
Original address: http://www.linuxidc.com/Linux/2012-01/52868.htm
Linux under the history command detailed---reproduced