27

I use ubuntu 11.04, and the question must be common to any bash shell. Pressing the up arrow key on your terminal will retrieve the previous command you had executed at your terminal.

My question is where(in which file) will all these command history be stored? Can I read that file?

Greenhorn
  • 1,811
  • 5
  • 21
  • 39

2 Answers2

43

the history filename was stored in variable : $HISTFILE

echo  $HISTFILE 

will give you the right file.

Usually in bash it would be ~/.bash_history, however it could be changed by configuration.

also notice that sometimes the very last commands is not stored in that file. running

history -a

will persistent.

history -r 

will clean those command not yet written to the file.

Kent
  • 189,393
  • 32
  • 233
  • 301
15

For bash, it is by default in ~/.bash_history (check the HISTFILE environment variable if it isn't). You can directly cat the file or use the history command.

Chewie
  • 7,095
  • 5
  • 29
  • 36