Learn how to disable history usage using HISTSIZE. Our Server management Support team is here to help you with your questions and concerns.
How to disable history usage using HISTSIZE
The Bash shell is a powerful tool that executes commands and keeps a record of your interactions. Today, we are going to take a look at Bash history and explore variables like HISTSIZE and HISTFILE. We will also learn how to customize and disable command recall as needed.
Exploring Bash History Variables
- HISTSIZE:
The HISTSIZE environment variable decides the number of commands that the shell should remember in its history list. By default, Bash displays the 500 most recent commands, listed from the earliest to the most recent execution.
Additionally, we can find out the number of commands saved in history, with either the echo or printf command:
$ echo "$HISTSIZE"
Or
$ printf "%d\n" $HISTSIZE
Hence, the value returned will tell us how many commands the shell is configured to save in the history list.
- HISTFILE and HISTFILESIZE
The HISTFILE variable holds the name and location of our Bash history file, typically “.bash_history.”
On the other hand, HISTFILESIZE decides how many commands can be stored in this file. Furthermore, it works with HISTSIZE to make sure that the correct number of commands is maintained in the history file.
For example:
$ echo $HISTFILESIZE
1000
$ echo $HISTFILE
/home/bob/.bash_history
Here, the HISTFILESIZE is set to 1000, aligning with the HISTSIZE value, and the history file is located at “/home/bob/.bash_history.”
Customizing Bash History
Did you know that we can modify HISTSIZE according to our needs?
For example, we can change the number of commands saved by HISTSIZE to 1500:
$ export HISTSIZE=1500
So, this will let the shell keep a broader history.
Similarly, we can disable Bash History by setting the HISTSIZE variable to 0 as seen here:
$ export HISTSIZE=0
Now, if we check the history, no commands will be displayed:
This is useful when we want to keep certain commands confidential or prevent sensitive information from being stored in the history file.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts demonstrated how to disable history usage using HISTSIZE.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments