What are processes and how can we manage them in Ubuntu

process-cover

Today Ubuntu (and most GNU / Linux distros) have a Complex user interface, which allows the user to use the System almost without knowing anything about it, and that's fine. It starts from the premise that the user does not have to have advanced knowledge, and that is why the use of Ubuntu and GNU / Linux in general is increasingly intuitive.

Now, it never hurts to know how what we are using works. Furthermore, we know that if you use GNU/Linux it is partly because of your disagreement, your curiosity and your desire to learn. So in Ubunlog We want to write a somewhat more technical article and show you what are the processes and how do they work in Ubuntu. We will teach you to list the running processes, to find a specific process and to kill them. We begin.

As we all know, Ubuntu (GNU / Linux) is a multitasking Operating System. This means that it is capable of executing several processes (tasks) simultaneously, without problems between them.

But… What is a process?

A process is nothing more than an instance of a program. Or put another way, a program is nothing more than a series of processes that are running. So in a colloquial way, a process could be understood as a running program.

The processes, as some of you already know, can be executed in two ways; in background (in the foreground) or in background (in background).

In addition, for the most curious, a process also has a state, since not only can it be running. If for example a process A launch another process B, A becomes known as the process father and B as the process hijo (child). Most often, when this occurs, A stay in state discontinued.

We can see it with an example:

Si we open the Terminal of our Ubuntu, we are already launching a new process, since the terminal is another program. What if from the Terminal we launch another program, we will see that it is suspended. That is, if once the Terminal is open, we execute:

gedit f_test

to open a new file called f_test (with the Gedit text editor), we will see that the terminal is suspended and that "we can no longer use it". If we wanted to continue using that same Terminal after launching the process, just launch it in background (background), that is, it is enough that we execute:

gedit f_test &

The symbol "&" indicates that we want this process to be executed in background. In this way, once the process is launched, we can continue using the Terminal, since it will not have been suspended and both processes will continue to run normally.

How can I know what processes are running on Ubuntu?

To see the list of processes that are running, just open a Terminal and run:

ps-aux

And we will see an output like the following:

Screenshot from 2016-05-22 16:19:21

The only information that interests us from the list is the PID. The PID (Process Identifier) ​​is an integer that, as its name indicates, is responsible for identifying a single process.

In addition, Ubuntu (and all GNU / Linux distros) have a file that determines the maximum value of the PID. This obviously determines the maximum number of processes to run. The file is called pid_max and it's inside the / proc / sys / kernel / directory. If you want to see its content quickly, just run:

cat / proc / sys / kernel / pid_max

And you will see how, by default, the maximum number of processes that can be executed is 32768. It is important that you walk carefully when moving through these directories, since a bad change could be fatal.

On the other hand, if we want search the processes associated with a certain program we can use a pipe and the grep command to filter the result. That is, if for example we want to see all the processes associated with Gimp, we can execute:

ps-aux | grep gimp

Screenshot from 2016-05-22 16:25:53

As you can see, in my case there are 3 processes associated with Gimp.

And ... How can I kill a process?

Killing a process means ending it, sending the corresponding signal for the process to end. To do so is as easy as using the command kill. This is where we need to know the PID of the process we want to kill. In the example above, let's say I want to kill the Gimp process that has 5649 as its PID. Well, just run:

kill 5649

Now how can I kill in one go all processes associated with a program? Very easy too. If in my case I want to kill all Gimp processes, I can use the command kill. As follows:

pkill gimp

This would kill all Gimp processes, that is, processes with PIDs 5649, 5719 and 5782. Easy right? If a program freezes and you didn't know how to end it, now you have a possible solution 😉

We hope this little guide has helped you understand a little better how Ubuntu and Linux work in general. Knowing how to work and manage processes is basic in Linux and at the same time very important. Still we know that this guide has been quite simple and concise, so if you are curious and want to delve into the subject a bit, you can take a look at the process life cycle or Linux Scheduler (process planner).

Until next time 😉


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Alfredo Ishmael Gontaro Vega said

    than good

  2.   Luisi said

    I am looking for a guide in pdf that explains to me by means of diagrams how processes are managed in Linux Ubuntu. By means of graphics things are better seen.