history is a very useful command in Linux, because it helps you remember the commands you have used in the past.
Well, the way most of people use it, is by typing
In the shell, and then copying the command to use it again, but there are some other ways, CTRL+R is another one, but there is also another one, and is to navigate in the list of history commands, using the index it has.
Here is how to do it.
Start a history substitution, except when followed by a space, tab, the end of the line, ‘=’ or ‘(’ (when the extglob shell option is enabled using the shopt builtin).
Refer to command line n.
Refer to the command n lines back.
Refer to the previous command. This is a synonym for ‘!-1’
Refer to the most recent command starting with string.
Refer to the most recent command containing string. The trailing
‘?’ may be omitted if the string is followed immediately by
Quick Substitution. Repeat the last command, replacing string1
with string2. Equivalent to !!:s/string1/string2/
The entire command line typed so far.
As you can see, there are lots of options to use history, so learn to get the most of it, you will enjoy it.
Thanks to gnu.org