Everytime you enter a command in shell. It will be store it a file for later use, so you can retrieve back the command later. History is use to show all the pass command you have enter in the shell, but history only shown a limited number which have been set in a configuration file:
the output will be something like this:
494 vim /var/log/faillog 495 cd .. 496 ls 497 htop 498 top 499 htop 500 uname
You may wonder how you can re-enter back the command listed above, actually it is simple. For example if you want to enter back the command number 496, you can just enter:
the ‘ls’ command will be used. How about the previous command which start with ‘vim’, you can simply enter
and so following command will be used
or you can using
history | grep vim
and the output will be
so usually I add these to my aliases file:
alias hg='history | grep'
next time i just using
to search for the command which have the ‘vim’ word.