【Foreground and Background Processes in Linux】What Are They? ▷ 2022

Are you learning to Well, one of the requirements is manipulate jobs or processes from your terminal. In this environment determining which ones are in the foreground and background is vital.

Also called background (compared to the first) and background (Regarding the second) each one has its particular objectives. These types are used depending on the kind of program to be executed..

In addition to this, it can vary depending on the way you want to work. You must also add other basic commands to understand, “jobs” either “” for list each process. Here you will learn to stop, suspend or move them like an expert.

What is a foreground process and what is it for?

When we run a program from the terminal, we usually do it in background. As soon as we insert its name, it will eclipse the entire console. This means that no other command will be supported until the process is complete. This mode is useful when programs require interaction with the user. Note that if you want to stop the current process in background just press the shortcut Ctrl + Z.

Be careful with this function when the tasks you are running are critical. By doing so you will already be pausing the software and you can start another one. Actually, when you enter CTRL + Z you are taking the execution to the background, but paused. The important thing is that you can once again take control of the console. Finally, you may want to stop the program immediately without pausing it.

See also  【 ACTIVATE JAVASCRIPT All Browsers 】 Step by Step ▷ 2022

After you are sure of your decision, press CTRL + C. Or if you prefer to do it directly from the console insert the argument kill. Said command must be followed by the number or program ID seen in the listing. You will have a result similar to kill %3. It is at this point that the question arises. How do I see the list of executed jobs? Well, continue reading and you will understand how to do it. But before What differences exist between background Y background?.

What are the differences between a foreground process and a background process?

We know that in background the terminal it will not accept any additional arguments until the end of the process. On the contrary, the processes in background consist of that the user can continue entering commands. The interpreter will accept them without problems since the execution work is hidden. This is its main difference, but it also helps the terminal not to stay open. This way it will not show excessive output data, nor will there be error messages.

There will not even be the danger of stopping the process. The latter will obviously affect the task as it has not been executed well. Furthermore, when we decide to run the hidden program is because it does not require interaction. In this way we can save time and carry out other operations from the same console. Given the does not overshadow the terminalis relevant for download files, scripts and more.

With this in mind, for start a background program from the beginning you have to use the argument & (ampersand). The correct way to use it is by writing the name of the software to be executed and then the ampersand &. Let us then imagine that our program is called “myprogram”. So the syntax should look like $ myprogram &. if you do it this way you will work software that may consume a lot of CPU resources. But they don’t really need any kind of human interaction.

See also  【 Fix Discord Not Opening Error 】 Step by Step Guide ▷ 2022

Learn how to see a list of foreground and background processes in Linux

To achieve this goal, all you have to do is follow these simple steps:

  • Being in the terminal you place the argument jobs, which literally means processes
  • This is how it will appear to you a list of jobs or processes that are running
  • next to its can also reflect those that have been paused or are suspended
  • the syntax it’s simple $ jobs

Possibly something similar to this appears:

+ Running myfrisprogram & – Stopped mysecondprogram. + Running Mythird Program &

Another alternative is to use the argument ps(process status) thanks to this we will see the list and along with it other characteristics:

  • For example, PID (Unique ID of the executed job) TIME (time since launch) and CMD (specific software or file name) The syntax could well be ps -A to receive a list of all active jobs and descriptions.

If, in addition to the above, you need to see the list of programs in background or want to bring one to the foreground is simple:

  • detects which are being executed through jobs
  • Write fg followed by the run id
  • For example: fg %3

East would bring up the process that has the ID or number 3 in position to background, which would run without interruption.

On the other hand, if you want to continue working a paused program in the background, use bg:

  • insert bg followed by the number of the paused software or job
  • Thus you should have a result very similar to this bg %3.
Loading Facebook Comments ...
Loading Disqus Comments ...