If I type the following:

history -c

I get 1110 history.

Why does clearing the command history not reset the counting to 1 and how can I reset the count?

Note: It is resetting the number, just not to 1. If I type 5 commands, the number changes to 1114 but history -c only resets it to 1110.

1 Answer 1


From bash man page:

On startup, the history is initialized from the file named by the variable HISTFILE (default ~/.bash_history)...

When an interactive shell exits, the last $HISTSIZE lines are copied from the history list to $HISTFILE. If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is overwritten...

So, only on exit the file ~/.bash_history is updated, and if histappend is set, the default, that file is not overwritten.

My suggestion, remove ~/.bash_history, then perform history -c.

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.