# How to Re-run Last Executed Commands in Linux?

Operating SystemLinuxMCA

Re-running commands in the command line is a regular task which all of us go through when working on the Unix systems. In the below article we will see various ways how we can rerun the commands we have already executed this helps save time and it helps reasoning longer commands easily without retyping them.

Before we get into how to re-execute previous command let's see how we can look at the list of all the commands. There is a command call history which lists down all the executed command for a specific time period configured by the system. Below is an example of how to execute the history command and see its results.

$histrory Running the above code gives us the following result − $ history
1 perl -v
2 sudo -apt update
3 cal
..
..
231 curl -s https://ipvigilante.com/122.175.62.177
232 curl -s https://ipvigilante.com/104.80.62.56
233 ls -l

## Up and Down Arrow Keys

In the terminal on pressing the up and down arrow keys we can revisit the command already executed repeatedly pressing them helps us cycle through all the commands that we have executed going forward and backward among each of them.

## Using !!

This command only execute the previous command./p>

$!!  Running the above code gives us the following result: ls -l total 60 drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 13 19:35 Desktop drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 13 01:58 Documents drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 13 19:40 Downloads ………. ………… ## ! with Specific Command If you want specific command from to be executed but you only remember a part of that command then you can use the! With part of the command I am the full command will get executed. $ !nsloo

Running the above code gives us the following result −

nslookup www.oracle.com
Server:127.0.1.1
Address: 104.80.62.56