Ubuntu – How to set HISTSIZE for all users

bashbashrccommand linehistory

How can I set HISTSIZE for all users on Ubuntu 10.04?

I've tried adding the following lines to both /etc/profile and /etc/bash.bashrc. I'm not sure I understand the difference between the two files but I really think either one should work on an interactive shell, right?

export HISTCONTROL=erasedups:ignorespace
export HISTSIZE=5000
shopt -s histappend

For some reason this won't work though. I have added the lines to the bottom, logged out, logged back in, and typed echo $HISTSIZE and I get "1000"?

What am I doing wrong?

Best Answer

  • Thanks @lesmana, you are correct. I have added the block of code to /etc/bash.bashrc and made sure it was not in any of the users profiles. That worked well. I also realized that I should set it in /etc/bash.bashrc and not /etc/profile because the first one is for bash (which history is pertinent to) and the second one is for Bourne shell (sh(1)) and Bourne compatible shells (bash(1), ksh(1), ash(1), ).