How many commands will be saved under the Linux system and the history command? Once in a book, if the system is unregistered, then all the historical commands will be set into the ~/.bash_history,
However, only 1000 commands are reserved (this is set by the default shell variable) But why do we have a history of more than 1000 after we execute the historical command?
In fact, when we look carefully only the sequence is greater than 1000, the number of records or 1000.
Here is how I understand:
1, ~/.bash_histroy inside is the record of the previous log off history ( Max Save 1000, and is the last time before the 1000 records )
2. The history command will show the records in the ~/.bash_history plus the records executed by the current shell. It also shows only 1000 records, such as after re-login, after executing the LS command, then using history to view,
will display the. Bash_history in the +ls and history of these two articles. If there are 1000 articles in the ~/.bash_history, then The two commands are shown after 998+ls and history.
3, we can modify the history of historical reservation of the number of commands; You can see the default number of retention bars for the record echo $HISTSIZE generally default to 1000 as shown:
What if we only need to keep 200 of them for security? We can temporarily modify the maximum number of retention bars:histsize=200 This is changed to 200, but after restarting the server, and then restore.
If you want to keep 200, we need to modify his environment variables in/etc/profile, you can use Vim to edit it (it is recommended to use Vim editing), or you can use SED to modify it directly. The command is as follows:
[Email protected]'s/^histsize=1000/histsize=200/'/etc/profile[[email protected]// make it effective immediately
This way, even after restarting the server, the history command retains 200 remaining bars until the next histsize variable is modified.
Linux Modified History Record Count