How to change ‘history’ command output

command linehistoryterminal

So by default .bash_history stores 500 last used commands. I changed that to 5000 by setting HISTFILESIZE=5000 in .bash_profile It seems to work.

Now when I do history it still prints 500 commands, but now it does so not from 1 to 500, but from 36 to 535 (earlier commands are stored but not printed).

I'd like for history to print 1000 last used commands. How can I achieve that?

Also recently I tried history -a and haven't noticed anything change. What does this command do? Man history doesn't help.

Best Answer

In addition to HISTFILESIZE, you also need to set HISTSIZE, which controls the number of commands to keep in memory until they are saved.

Also, the manual page for history is available via man bash. Scroll down to SHELL BUILTIN COMMANDS, and you'll find it. The details about HISTSIZE and other variables are further up in the same manual page.