Some valuable or complex commands may not be able to keep in your mind constantly when you need them. In this moment, you can leverage the command history to recall them. But as time goes by, you could lose them due to the size limitation of command history.
The history always keep the most recent command lines in ~/.bash_history. The limitation of size is controlled by $HISTSIZE and default value is 1000 which could be too low for recalling more valuable commands. That's why you should increase bash history size of commands.
Increase Bash History Size For Personal Setting
You should export the value of HISTSIZE in ~/.bash_profile- Here are the steps:
- Open your ~/.bash_profile in vi
- Export HISTSIZE into any value larger than 1000
- Take effect immediately
[scott@test ~]$ vi ~/.bash_profile
...
export HISTSIZE=10000
[scott@test ~]# . ~/.bash_profile
[scott@test ~]# echo $HISTSIZE
10000
Increase Bash History Size For Global Setting
You should change the value of HISTSIZE in /etc/profile
- Here are the steps:
- Open /etc/profile in vi
- Find a variable called HISTSIZE
- Modify the value of HISTSIZE into any value larger than 1000
- Take effect immediately
[root@test ~]# vi /etc/profile
...
#HISTSIZE=1000
HISTSIZE=10000
[root@test ~]# . /etc/profile
[root@test ~]# echo $HISTSIZE
10000
Don't worry about the growing file size of ~/.bash_history. Even you set 10000, it doesn't take that much space as you think.