The history command is used to display a specified number of command commands, to read the directory from the historical command file to the history command buffer, and to write the directory in the history command buffer to the command file.
When this command is used alone, only the history command is displayed, and on the command line, you can use the symbol to !
execute the history command of the specified ordinal.
The history command is stored in memory and is automatically saved or read when you exit or log in to the shell. In memory, the history command can only store 1000 historical commands, which are controlled by environment variables HISTSIZE
History Common Command parameters
-C: Clears the current History command;-A: Writes the command in the history command to the history command file "/root/.bash_history";-r: Reads the command from the history command file into the current History command buffer;-W: Writes the current History command buffer command to the history command file "/ Root/.bash_history ";
N: Print the most recent n history command
# History will list all the historical commands that bash has saved, and they are numbered, and we can run a specific history using the "exclamation mark Number" method
!+ Letter: Call up the most recent command that starts with this letter!!: command that represents the most recently used operation!+ Number: A few commands to bring up the history-number: Bring up the last few commands
Common Command Display
History command Show Execution Time "show ordinal and command by default"
# Temporary effect
[Email protected] ~]# export histtimeformat= '%F%T ' [[email protected] ~]# echo $HISTTIMEFORMAT [[email protected] ~]# hist Ory 2
# Permanent Effect
[Email protected] ~]# vim/root/.bash_history
---> add Export histtimeformat= '%F%T '
Source/root/.bashrc
View the number of caches for history
# view variables directly [[email protected] ~]# echo $HISTSIZE # View file contents [[Email protected] ~]# cat/etc/profile | grep ' histsize ' Note: HIST Size=0, indicating that history is disabled
See the last 10 commands
[[Email protected] ~]# history 10
Use the last command you used
[[email protected] ~]#!!
Use the NUM Bar command
[Email protected] ~]#!994
Show a specific command that was recently used
[Email protected] ~]#!echo
Get the arguments for the previous command
[email protected] ~]# ls sun.txt [[email protected] ~]# cat!$
Linux History Command Details