Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Can I increase the size of the command history in bash?

Note that I use a Red Hat Linux computer in the undergraduate astrophysics department here (so I don't get that many privileges).

share|improve this question
maybe you could ask this question on this site proposal: undergraduates‌​. Follow it if you find it interesting! – Daniele B Jan 23 '13 at 17:11
up vote 12 down vote accepted

Instead of specifying numbers, you can do

shopt -s histappend

in which case only your disk size (and your "largest file limit", if your OS or FS has one) is the limit.

However, be aware that this will eventually slow down bash more and more. see here and here for better ways.

share|improve this answer
You may also have to increase history-size in your inputrc. – Chris Down Sep 18 '11 at 21:07

You can use logrotate to preserve old entries. It allows you, for example, to set size limits that will trigger archiving. It is normally run from a daily cronjob, but you might just as well invoke it from your .bash_logout script.

share|improve this answer

@Philomath, unsetting those environment vars does not work for me at all! For me, this causes bash to use its inbuilt defaults (it seems) of truncating .bash_history to about 9KiB.

What does work for me is the following in my .bashrc:

export HISTSIZE=
shopt -s histappend
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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