The command line is a powerful
and writing shell scripts lets you write a series of commands once
and replay them any time you like.
But sometimes you will write a series of commands without putting
them into a script. This may be because you are exploring a problem
or because you haven’t bothered to put together a script. No sense
in making something repeatable if you aren’t sure exactly how you
are going to repeat it.
But you may want to look back over past commands you have run,
whether to run them again, modify them or even just remind yourself
what you’ve done. For this, the shell history is very handy. Another
time I often look at the shell history is when I am signing into a
machine that I don’t visit very often. Perhaps there’s a command to
look at some log files that I know, distantly, in the back of my
mind, that I ran four weeks ago. I could have documented it, but
maybe I didn’t. If I look in my command line history, I can see it.