2 Ways To Recall And Run Previous Commands In Linux Mint / Ubuntu

The Linux command prompt/shell records previously entered commands in the form of history. This is convenient because any of the previously used commands can be recalled and run again when needed.

Now, to see a list of all previously used commands, type “history” at the command prompt.

using history to show list of previously used commands in linux mint/ubuntu

This will show a numbered list of all the commands with each number corresponding to the command next to it.

1st way:

Once the history displays the numbered list, here is how that can be used to recall and execute previous commands :

Type :

!commandnumber

For example, the command “pwd” shown below has a number 247 associated with it, so typing it will execute that  :

recalling command using number

2nd way :

A simpler way to do this without looking up numbers is to just type the partial command name  :

!partialcommandname

The example below shows how a partial “who” command will recall and execute that specific command.

using partial command name to recall and run commands in linux mint/ubuntu

One thing to note when doing this is that if there are more then one such similar commands (in the above example a “uname -i”, then later followed by a “uname -a”, the most recent one will be executed which would be “uname -a” in this case).

recalling previous commands in linux mint/ubuntu

Isn’t Linux command line awesome!? 🙂

[To know different kinds of commands in Linux Mint/Ubuntu and how to use them efficiently, please refer to our multi-part Linux command line basics series starting from here. ]

 

 

Comments are closed.