Today Ubuntu (and most GNU / Linux distros) have one Complex User Interface, Which allows the user to use the System almost without knowing anything about it, and that’s fine. It is based on the premise that the user does not have to have advanced knowledge, which is why the use of Ubuntu and GNU / Linux in general is increasingly intuitive.
Now, it never hurts to know how what we’re using works. Also, we know that using GNU / Linux is partly because of your dissatisfaction, your curiosity, and your desire to learn. So in Ubunlog we want to write a slightly more technical article and teach you what processes are and how they work in Ubuntu. We will teach you how to list running processes, search for a particular process, and kill them. Let’s get started.
As we all know, Ubuntu (GNU / Linux) is a multitasking Operating System. This means that it is able to run several processes (tasks) simultaneously, without any problems between them.
Table of Contents
But … What is a process?
A process is nothing more than an instance of a program. In other words, a program is nothing more than a series of processes running. So in a colloquial way, a process could be understood as a program that is running.
Processes, as some of you may already know, can be executed in two ways; a foreground (In the foreground) or a background (Background).
In addition, for the most curious, a process also has one state, As it can not only be running-. If for example a process A launches another process B, el A it becomes known as the process pare and the B as the process son (child). The most common is that when this happens, A stay in condition suspended.
We can see it with an example:
Yes we open the Terminal of our Ubuntu, we are already launching a new process, as 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 run:
gedit f_prueba
to open a new file named f_test (With the Gedit text editor), we will see that the terminal is suspended and that “we can no longer continue to use it.” If we wanted to continue using this same Terminal after launching the process, we just need to launch it at background (Background), that is, we just run:
gedit f_prueba &
The “&” symbol indicates that we want this process to run on background. In this way, once the process is launched, we can continue to use the Terminal, as it will not be suspended and both processes will continue to run normally.
How do I know what processes are running on Ubuntu?
To see the list of running processes, just open a terminal and run:
ps -aux
And we will see an exit like the following one:
The only information we are interested in from the list is PID. The PID (Process Identifier) is an integer that, as its name suggests, 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 be executed. The file is called pid_max and is inside the / proc / sys / kernel / directory. If you want to see the content quickly just run:
cat / proc / sys / kernel / pid_max
And you’ll see how, by default, the maximum number of processes that can be run is 32768. It’s important that you walk carefully moving — through these directories — as a bad change could be fatal.
On the other hand, if we want to look for the processes associated with a particular program we can use a pipe and grep command to filter the result. That is, if for example we want to see all the processes associated with Gimp, we can run:
ps -aux | grep gimp
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 this 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 end the Gimp process that has 5649 as PID. So just run:
kill 5649
Now how can I kill in one fell swoop all the processes associated with a program? Very easy too. If in my case I want to kill all Gimp processes, I can use the command pkill. As follows:
pkill gimp
that 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. However we know that this guide has been quite simple and concise, so if you are curious and want to delve a little deeper into the subject, you can take a look at process life cycle oal ‘ Linux scheduler (Process Planner).
Until the next 😉