Linux Modified History Record Count

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.