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.

After finding out what this shopt -s histappend means, it seems a very sane setting, and I'm surprised that it isn't default. Why would anyone want to wipe their history on each shell exit?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

Well, when histappend is not set, this does not mean that the history is wiped on each shell exit. Without histappend bash reads the histfile on startup into memory - during operation new entries are added - and on shell exit the last HISTSIZE lines are written to the history file without appending, i.e. replacing the previous content.

For example, if the histfile contains 400 entries, during bash runtime 10 new entries are added - histsize is set to 500, then the new histfile contains 410 entries.

This behavior is only problematic if you use more bash instances in parallel. In that case, the history file only contains the contents of the last exiting shell.

Independent of this: There are some people who want to wipe their history on shell exit because of privacy reasons.

share|improve this answer
Also, for security reasons, it can be a good idea to not save history for the root user. This feature allows root to have a shell history without it ever being saved to disk. –  Mei Feb 4 '12 at 0:50

For historical compatibility, I guess. The histappend option didn't exist until bash 2.0.

share|improve this answer
Was history overwritten each time? –  Tshepang Jan 27 '11 at 4:59
@Tshepang: Yes, same as now if you don't use histappend. –  Gilles Jan 27 '11 at 8:22

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.