/ Linux

Previous Article

Running Linux Commands in the Background

Next Article

When running a large complex command or time consuming command such as moving a large quantity of files from one drive to another or running a mass rename script, your terminal will become locked and only become available when that command has finished running.

To bypass this and run the command in the background simply append an & to the command. You will then be given a process ID of the command as it runs in the background.


command &

Here is a working example. I want to move all my .arw files from one drive to another, as i have quite a few large arw files this process takes up a lot of time. I also tend to access my linux box via ssh so don't want multiple connections to the terminal. This is the command i run:

mv *.arw /media/photos/ &

To see what jobs you have running use the following command


The following is a sample output that will be returned by this command

[1]+ Running mv *.arw /media/photos/ &

The [1] returned is the job ID, if you want to see the process ID then pass the -l option as below

jobs -l

This will return the same information as the main command but also include the process ID which is  useful if you want to kill a process. See sample output below:

[1]+ 30125 Running mv *.arw /media/photos/ &

If you want to bring the job to the foreground use the following syntax:


so for our example:


This will then show the command that you are running with any output in my case it will just display:

mv *.arw /media/photos/

To send it to the background again simply ctrl + z and then %1 & this will run it again in the background

Avatar of Clive Walkden

Clive Walkden

Latest Articles


Output All Users Cron Jobs

If you want to check all users cron jobs this little command will output them to the command line

Magento 2

Magento 2 admin password history reset

Do you want to clear the password history on your staging test site (not recommended for live)?


How to see files changed on a certain date

As a sysadmin you often need to see which files have been modified on a certain date.