Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to increase the size of my history in bash. I have the following in my ~/.bash_profile

# Control the command history
export HISTFILESIZE=10000
export HISTSIZE=10000
export HISTCONTROL=ignoredups:erasedups
But, when I echo $HISTSIZE I always get 50. Am I missing something? Is there some command that my sys admin put in a higher config file that could prevent HISTSIZE from being changed?

share|improve this question

migrated from Sep 24 '12 at 13:25

This question came from our site for professional and enthusiast programmers.

What happens when you echo $HISTSIZE immediately after you export it? Do you still get 50 in that instance? – Dunnie Mar 30 '11 at 14:23
@Dunnie Good question. ~$ echo $HISTSIZE 50 ~$ export HISTSIZE=100 ~$ echo $HISTSIZE 100 ~$ So I can set the HISTSIZE on the command line, but not in my .bash_profile. – jlconlin Mar 30 '11 at 14:59
And do you get the same output if you place the echo in your .bash_profile? I'm basically trying to determine if your .bash_profile just isn't setting it at all, or if it's getting overwritten later on down the line. – Dunnie Mar 30 '11 at 15:07
@Dunnie Yeah, you were right. One of those files sources something that changes HISTSIZE. I have changed the order of the sourcing of files and now it works. Thanks for your help. – jlconlin Mar 30 '11 at 17:23
up vote 3 down vote accepted

Many distributions seem to have .bash_profile check .bashrc somewhere inside of it. Could your .bashrc be sourced sometime later and set a HISTSIZE of 50?

share|improve this answer
I have checked .bashrc and (on this system) .bashrc.local; both are called after .bash_profile, neither contain anything about HISTSIZE. – jlconlin Mar 30 '11 at 14:59
Does your .bash_profile (or any descendants) source any other files? /etc/profile might also be a culprit. – Miles Strombach Mar 30 '11 at 15:25

What is your OS and BASH version? try


I use 4.2.20(2)-releasevia Mac OS X Lion / Homebrew... Here is my config

export HISTIGNORE="ls:ll:cd:pwd"
export HISTFILESIZE=3000
export HISTSIZE=3000
export HISTCONTROL=ignoredups:erasedups
export HISTTIMEFORMAT="[$(tput setaf 6)%F %T$(tput sgr0)]: " # colorful date

Try to update you bash. Also, maybe ~/.bashrc or /etc/bashrcor /etc/profile is overriding your local settings...

share|improve this answer

Try setting the variables in /etc/environment.

share|improve this answer
Putting HISTSIZE=5000 or HISTFILESIZE=5000 in /etc/environment does nothing for me. I'm in Arch Linux. – trusktr Oct 4 '12 at 4:54
Oh, wait, putting the variables in ~/.bashrc or /etc/bash.bashrc works. – trusktr Oct 4 '12 at 5:46
It works, but it seems to require me to login again? Because I have a proof that nothing has changed, because cat ~/.bash_history | wc -l gives a clear 2000, which is the default - and I have set about twice as much. From bash manual it states: "The shell sets the default value to the value of HISTSIZE after reading any startup files." Maybe, but it will NOT expand a .bash_history file that already exists. It stays at the default of 2000 lines. So before trusting bash, you should execute the above line to know it isn't trying to fool you. – syntaxerror Dec 9 '14 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .