1

I've been trying to change the HISTSIZE system wide and it hasn't been working. I've tried multiple different methods :

  1. adding /etc/profile export HISTSIZE=100
  2. adding /etc/enviroment HISTSIZE=100
  3. adding /etc/bash.bashrc HISTSIZE=100

I don't want to change the per-user .bashrc file.

  • 1
    Did you logout /login again? – Romeo Ninov Jan 8 at 8:50
  • or alternatively run source /etc/profile or whatever file you change – RobotJohnny Jan 8 at 9:09
  • How do you log into this machine? Have you added that line to all of those files or do you remove it from one and then add it to the other? Are you sure your user(s) doesn't have a different setting? Anything in the per-user file will overwrite the globals. – terdon Jan 8 at 9:44
  • I assume /etc/enviroment is a typo for /etc/environment? – Jeff Schaller Jan 12 at 15:18
1

TLDR; See where HISTSIZE is changed:

grep HISTSIZE /etc/profile /etc/bash.bashrc ~/.profile ~/.bash_profile ~/.bash_login


The HISTSIZE is just an environment variable and environment variables are set or overwritten in a few places. I will assume you are using bash (I'm sure other shells also use HISTSIZE, but bash is often the default shell)

The default HISTSIZE is 500 as you can see in the bash/bind.c: https://github.com/bminor/bash/blob/d233b485e83c3a784b803fb894280773f16f2deb/lib/readline/bind.c#L2040

When a user logs in, a pretty complex tree of config files is loaded. Here is an excellent post about this: https://blog.flowblok.id.au/2013-02/shell-startup-scripts.html

And here is the relevant diagram from that post: enter image description here

Now, when running a normal, interactive, remote (purple line) shell you can see the following files are parsed:

  • /etc/profile
  • /etc/bash.bashrc
  • ~/.profile
  • ~/.bash_profile
  • ~/.bash_login

Any of these files can set or change the HISTSIZE variable.

Now you can read the current HISTSIZE variable by typing:echo $HISTSIZE

If the result is an empty line, it was not set and the default 500 should apply.

Any other amount will have been set by other scripts in the list above. You can have a quick look by grepping for HISTSIZE like this: grep HISTSIZE /etc/profile /etc/bash.bashrc ~/.profile ~/.bash_profile ~/.bash_login

  • That diagram... It serves the purpose of showing that "it's complex", but to try to decipher it is not really useful, especially since it differs between Unix systems (and the system for which the diagram was created is not mentioned). Note that bash on two different systems also may differ in the way it's invoking some startup files. The real reference is the system's own bash(1) manual. – Kusalananda Jan 8 at 11:16

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.