I'm trying to understand something about environment variables, and I checked through some common ones listed in an LPIC exam guide. It talks about HISTSIZE among other HIST variables, but it says that HISTSIZE and things like HISTCONTROL are common environment variables. However my testing is inconclusive. In my test below, i check if HISTSIZE is a global environment variable, but it's not. But when I echo it, I see a result, so my assumption is that its a local/shell variable. However, I spawn a new bash child-shell and the value is still there, so it must be a global/environment variable. So how is it not int he result of printenv or export?

$ printenv HISTSIZE
$ export | grep HISTSIZE
$ echo $HISTSIZE
$ bash
$ echo $HISTSIZE

1 Answer 1


From the manual [emphasis mine]:

The maximum number of commands to remember on the history list. […] The shell sets the default value to 500 after reading any startup files.

Your new bash did not get HISTSIZE in the environment, it set HISTSIZE for itself. The value you observed is not the default, so it must be somewhere in your startup files. In my case HISTSIZE=… is in ~/.bashrc.

  • Right I get it. So basically it's not an environment variable. However since it's in the .bashrc file, whenever I spawn any kind of shell that variable will be available since .bashrc is read on either login or non-login shells. So programs will always be able to find it. I'm guessing that the lpic 102 lesson 2 topic on this is wrong then, because it's simply not an environment variable by definition. However it is available because of the way the .bashrc script is ran when users open new shells.
    – john smith
    Commented Dec 7, 2022 at 12:50
  • @johnsmith, it is an environment variable by definition, the definition of an environment variable in bash is basically any variable set on the session, at least that is how I understand it. In what sens it is not an environment variable by definition for you? Commented Mar 8, 2023 at 22:28

You must log in to answer this question.

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