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?
Here's how: Open Start. Search for Command Prompt, and click the top result to open the console. Type the following command to view the command history and press Enter: doskey /history.
To see the list of recently executed commands in CMD, press the F7 key. This will open a pop-up inside CMD showing the list of recently executed commands. You can select any command and press enter and that specific command will be executed again.
Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With