Processes and Jobs in Linux  Step by Step Guide ▷ 2020

While it is true, one of the most recognized operating systems, like, Windows Y MacOS, it’s Linux. Which, has its origin in Unix, can be used through a graphical interface and basically, consists of software that offers the possibility of using programs such as text editors, web browsers and games.

Added to that, Linux stands out for being a multi-tasking, multi-user operating system, which implies that numerous processes have the ability to operate without interfering with each other, so simultaneous. In such a way, each process will have the illusion that it is the only one in the system and that it has exclusive access to all the services of Linux.

Now, given this operation, users wonder what, actually, are the Processes and Jobs in Linux. Reason why, in this post, we will let you know what a process consists of Linux and what is it for, like how foreground and background processes are defined, as also what must be done to kill a process.

What is a process and what is it for in Linux?

In general terms, a process can be defined as a set of operations to which a certain element is subjected to elaborate or transform it. So in Linux and at the computer level, a process consists of an instance of a running program (ie from a running program). Therefore, the context of a program that is running, the essence of the process performed is considered.

Therefore, as Linux it is a multitasking system, there are multiple instances of a program that have the ability to run at the same time. So basically each instance will be a separate process. Thanks to this, a process in Linux is used to perform any kind of action or task in the operating system. Since practically everything that is running on it at any time will be identified as a process.

Including, the Shell and the graphic environment, for example, that can have endless processes. Now, among other details, it should be noted that each process It is defined by the program, the memory space it occupies and the “child processes” that it orders to call.

The latter being processes that are characterized by being an exact copy of the parent process, in order to call the corresponding task. That way, the main process or “parent process” will share with the “child processes” all the system resources that it is consuming and their security conditions.

Processes in the foreground and background How is one different from the other?

Processes in the foreground and background How is one different from the other?

On the Linux operating system, a process can be in the foreground or in the background. Which, despite the fact that it is such an important peculiarity, in many cases is not understood by the users of this OS. Therefore, it is important to know what these kinds of processes consist of and how they differ between the two.

So basically a process that is in the foreground is defined as the one that interacts with the user or, in other words, how that process that has the ability to receive keyboard inputs and send outputs to the monitor. The reason why, only one foreground process can exist at a time. On the other hand, the background process is the one that runs silently and without the need to exhibit any interaction.

Which means that it does not have the power to receive any signal from the keyboard or to show the outputs on the computer monitor. Consequently, the main difference between these two types of processes in computing is that the processes in the foreground, obligatorily, require some interaction with the user, so that it initiates and maintains them. Whereas, background processes are executed with total independence from the user.

Kill a process How do you end a process when it is no longer needed?

Kill a process How do you end a process when it is no longer needed?

In other operating systems, such as Windows, one of the tasks that the user knows best is to close an application unexpectedly or, in effect, terminate a process. However, unfortunately, in Linux this type of task are not unique to the operating system. Therefore, in said OS, just as there are processes in the foreground and background, there is also the possibility of suspend, terminate or kill a process when it is definitely no longer required.

In these cases, luckily, it is not complex to kill a process, since There are three commands whose objective is to carry out this action or to terminate an application, quickly. However, before making use of any of the three commands that allow killing a process in Linux, it is important to discern that you have to know the PID of the process you want to end. Being this, a type of identification that works like the DNI or the passport number of a person, so it is exclusive and unrepeatable.

Now, the commands we mentioned above are those that we indicate below:

For its part, to put the first named command to work, you have to know the PID of a process and fortunately this is simple.

Which, you can do it in the following way:

  • In the terminal, you have to enter the command called “htop”.
  • If you prefer, you can write “ps-A” directly in terminal.
  • When you carry out any of the previous steps, you will be able to view all the processes executed in the operating system, along with the programs they use and their corresponding PID.

At this point, when you already know the PID of the process you need to kill on your Linux computer, you will have to do the following:

  • If you need to kill a process that you have created as a user, you must use the command “Kill”. For that, you have to enter the exact formula which is: “Kill – 9 PID”. Thus, the “-9” indicates that you want to kill the process and “PID” it refers to the code of the process to be destroyed.
  • Yes, instead of using the PID of the program, you prefer to kill him by means of his specific name, you can use the command “Pkill”. In this case, you must use the command as follows: “Pkill mysql”.
  • If you choose kill the process and also the program or function to destroy all processes that depend on that program, it will be more effective to use the command “Killall”. An example of use would be this formula: “Killall Firefox”, that is, it also uses the name of the process (just like Pkill).

As a recommendation, it is best to use the command“Pkill”, since it is easier to use it to kill a process, quickly. But, if the system presents a serious problem and you want to exterminate it from the root, it will be more powerful to use the command “Killall”.

If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thank you! 😉

You may be interested:

Leave a Comment