How to send processes to the background on Linux

s2 0

When using an operating system, several processes can be run on it. These processes are mainly categorized into the background processes and the foreground processes. As the name suggests, a background process is a process that runs silently in the background without the need for human intervention. A foreground process, on the other hand, is the one that we actually see and with which we can continuously interact. We can even send a process to the background or bring a process to the fore according to our needs. To know how to do this, you need to go through this article.

Sending a process to the background on Linux

To send a process to the background in Linux Mint 20, you can use either of the two methods described below:

Method # 1: Using the “&” symbol:

This is the easiest way to send any process to the background in Linux Mint 20. All you need to do is type the name of the process you want in your terminal followed by a space and the “&” symbol and then hit the Enter key as shown below:

$ processName &

We wanted to let the Firefox process run in the background, so we replaced “processName” with “firefox”.

When this command is run, the Firefox process will immediately run in the background.

Method # 2: Using the “bg” Command:

To follow this method, you first need to start the process you want to run in the background from the terminal as follows:

$ processName

We wanted to start the Firefox process, so we replaced “processName” with “firefox”.

Run the app

As soon as you run this command, the Firefox browser will launch immediately, as shown in the following figure:

Fire fox

After that you have to press Ctrl + Z while you stay at your terminal and you will get a “Stopped” message on the terminal, as shown in the following figure, while you can still see an active Firefox window on your screen.advertising

Suspended process

Finally, you need to type the command shown below and then hit Enter:

$ bg

bg command

This command immediately sends the specified process to the background and assigns it a job ID, as shown in the following figure:

Send the running process to the background with the bg command

To confirm whether or not the specified process was successfully moved to the background, you can run the command shown below:

$ jobs

Order command

When you run this command, all background jobs will be listed. You can see your specified job in this list as shown in the following figure:

Get a list of running background processes

Moving a process to the fore under Linux

A process that was running in the background can easily be brought to the foreground using its Job ID, as shown below:

$ fg %jobID

Since we wanted to focus on the Firefox process, we replaced “jobID” with “1”. The job ID can easily be determined by executing the “jobs” command in the terminal.

fg command

Executing the “fg” command immediately brings the specified process to the foreground while the message shown in the following image is displayed:

Bring the process to the fore

If you want to check whether the specified process has been brought to the foreground or not, you can simply run the jobs command again and you will not find your specified job there. Since in our case there were no other processes running in the background apart from Firefox, the execution of the “jobs” command did not result in any output for us this time, as we were no longer running any processes in the background.

Empty job queue

diploma

So you can easily send any process you want to the background or bring it to the foreground by following this tutorial. In this way, you are able to manage the flow of these processes yourself.

How to send processes to the background on Linux
Tags: