In linux, view the history command history. In linux, view history.
1. Functions of history
Linux's history command is used to record executed commands. Usage: history [n] n is a number, list the latest n commands-c. Delete All history commands in the Current shell by using history [-raw] histfiles-a. Write the newly added commands to histfiles by default ~ /. The bash_history-r reads the histfiles content into the current shell's history Memory-w writes the content of the current history memory to histfiles
shell > history 34 14-10-28 16:19:24 ll 35 14-10-28 16:19:26 vim test 36 14-10-28 16:19:33 ll 37 14-10-28 16:19:34 ll
Show 3 rows
shell > history 3 1032 14-11-02 16:10:41 history 1033 14-11-02 16:10:46 history |more 1034 14-11-02 16:11:15 history 3
Use! Run the history command .! Number! Command from the latest command to find the command that starts with command to execute !! Run the previous
shell > !1046history 3 1045 14-11-02 16:22:38 head ~/.bash_history 1046 14-11-02 16:35:37 history 3 1047 14-11-02 16:35:48 history 3shell > !!history 3 1046 14-11-02 16:35:37 history 3 1047 14-11-02 16:35:48 history 3 1048 14-11-02 16:35:52 history 3shell > !headhead ~/.bash_history #1414484377cd update/#1414484377
2. Modify history configuration
Number of history records
shell > echo $HISTSIZE1000shell >
By default, the configuration file of Line 1 is modified in/etc/profile.
HISTSIZE=1000export HISTSIZE
The history command file is recorded in ~ /. Bash_history
To display the time of linux's history command, history does not contain time by default, and is added to/etc/profile.
export HISTTIMEFORMAT="%y-%m-%d %H:%M:%S "
View. bash_history
shell > head ~/.bash_history #1414484377cd update/#1414484377ll#1414484388vim address #1414484439ll#1414484440llshell >
3. The same account is logged on multiple times to write to history
In normal cases, when you log on to the system using bash, the system starts from ~ /. Bash_history read the previously run command. When logging out, update the latest 1000 (HISTSIZE) command ~ /. Bash_history file. You can also use history-w to forcibly write data immediately. Only the latest data is retained.
When you log on to multiple bash instances under the same account at the same time, only the last exit will be written to bash_history, and all others will be overwritten.
4. Ctrl + r reverse query history command
Use the Ctrl + r reverse query history command to display the latest matching record. If you want to continue the query, press Ctrl + r
shell > history 3 1048 14-11-02 16:35:52 history 3 1049 14-11-02 16:36:11 head ~/.bash_history 1050 14-11-02 16:41:05 history 3(reverse-i-search)`his': head ~/.bash_history
Address: http://blog.csdn.net/yonggang7/article/details/40710623
Ask how the linux history command displays all historical records
All commands are displayed by default. If not, open the. bash_history file in the main directory of the user.
Vi ~ /. Bash_history so that all the commands of the current user can be seen. Of course, history stores your latest N commands (default value: 200, which can be modified through parameters)
In linux, delete the history command. For example, the command history-c will be run in the last query records. How can I delete the last command?
History-c multiple times
[Root @ redhat script] # history-c
[Root @ redhat script] # history
50 history
[Root @ redhat script] #
I don't have one.