the ~/.bash_history
file in your home directory is where every single Linux command you have run in your terminal application is registered since you have installed your Linux distribution.
This is how you can navigate to previous commands that you ran in the terminal using the “Up” key on your keyboard; because all of these commands are already written into a file.
This feature is helpful so that if you ran a useful Linux command once and want to run it again after some time (e.g. few days or weeks), then you can always find it written in that file.
If you want to run a Linux command and don’t want it to show up in your commands history, then you can add a space before it so that it won’t be written into the ~/.bash_history
file:
mhsabbagh@PowerPC:~$ # This will be written in .bash_history:
mhsabbagh@PowerPC:~$ echo "something"
something
mhsabbagh@PowerPC:~$ # This will NOT be written in .bash_history:
mhsabbagh@PowerPC:~$ echo "something"
something
mhsabbagh@PowerPC:~$
Moreover, you can disable this feature altogether in your Linux distribution by appending the following line to the end of your ~/.bashrc
file so that the commands you run are no longer stored in that file:
export HISTSIZE=0
(You’ll need to close your terminal and restart it for changes to take effect).
Further interesting reading about the Shell history and much more entertaining things that you can do with it is available from the following reference: https://linux-training.be/funhtml/ch16.html
Hope this helps! 😃