Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

3 Answers 3

up vote 9 down vote accepted

Instead of specifying numbers, you can do

unset HISTSIZE 
unset HISTFILESIZE
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=
export HISTFILESIZE=
shopt -s histappend
share|improve this answer

Your Answer

 
discard

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.