Very basics of Managing processes in GNU Linux

Perhaps for many users on the Internet it is not easy to know what a concept is that it is a process or that it is a daemon process both in GNU / Linux and in other operating systems, so a brief citation of both concepts is consulted:

A resident service or program or Unix terminology daemon (erroneously translated to daemon) is a special type of program that runs in the background, rather than being controlled directly by the user. Source: Wikipedia.

It is already known that a daemon is a background process, but why do background processes exist?

Background processes are used in the case of operating systems to perform tasks that are not directly controlled by the user and that abstract the operation of the operating system, or in the case of programs or applications, they delegate certain functionalities that require delegating. information processing in a background task, for example applications that show information obtained in real time and have a background process thread that is responsible for obtaining said information from a specific source, without the user having to directly handle the refresh .

Now there is the possibility that these processes consume more resources of the computer or more computer there are for what they were programmed due to a malfunction, and for this there are programs that allow you to manage the programs that run in the background and in the foreground, thus allowing manage your computer’s RAM memory very easily and simply.

Programs used for the management of processes in the foreground and background

Among the most common programs used in GNU / Linux to manage processes in the foreground and background (in the terminal or console) the following can be mentioned:

  • ps, This command is by default in all or almost all GNU / Linux distributions and can be used from the beginning with a newly installed GNU / Linux system, it can be combined with other commands.
  • pstree, This is very similar to ps but showing a hierarchy of processes in a tree-like structure very useful to observe the dependencies between processes.
  • top, The top command is a classic to show the resources used by your system and thus be able to see which of them consume more.
  • htop, It can be said that it is a significant improvement on “top”, it is not usually installed by default in GNU / Linux distributions.
  • kill, a program that allows killing or stopping a process by means of its process id generally used together with the use of “ps”.
  • pkill & killall, With these you can kill processes by giving their name. This command is slightly different from the kill command for two reasons; It first uses the process name instead of the pid, and also sends the signal to all processes with the same name.
  • renice, This command is very interesting since it allows you to change the execution priority of a process.
  • atop, Real-time ASCII Process Monitor where it shows CPU, memory, network layers, active user, priority, etc. for each process.

In the case of the Graphical user interface, although somewhat more limited in what they can do, some can be listed:

  • ksysguard, kde desktop environment process management program.
  • system-monitor, This program is the default for the gnome desktop environment.
  • lxtask, This is part of the lightweight desktop environment lxde is simple but effective.

As can be seen in GNU / Linux, there is a very wide variety of applications for managing processes, one of which differs from the other either because of its simplicity or because of the more advanced functions available in them for managing processes.

The management of processes in the foreground and background is very common in operating systems and has not had many changes over the years, with it will continue the only thing that can change is how the processors handle those processes running in the operating system .

Do viruses run as background processes or daemons?

The answer is a complete and resounding YES, in fact, they develop them to run inadvertently in the operating system or even develop them in such a way that they use techniques to obfuscate themselves before the monitoring programs and process managers, although there are techniques to discover the themselves but mostly these are discovered in operating systems when they have already done the malicious task for which they were developed.

A mini how to do with ps and kill to manage processes through the terminal or console as super user or root

In a computerized society, it is currently the responsibility of the user himself to have the ability, even in a basic way, either through a graphic program or to interpret commands, to be able to manage and monitor the processes running in the operating system of the computer or smart phone that he is using. .

Well to start you just have to go to the command interpreter and execute the command:

ps

It will show the following:

PID TTY TIME CMD

11875 pts / 1 00:00:00 bash

14096 pts / 1 00:00:00 ps

It shows the bash terminal that we are using and itself as a running process, but how do we see the other processes and processes in the background? Well, executing ps with the argument -d (daemons) in the following way:

ps -d

It will show a long list of running processes in the foreground and background below a summary of the output:

PID TTY TIME CMD

two ? 00:00:00 kthreadd

3 ? 00:00:00 rcu_gp

4 ? 00:00:00 rcu_par_gp

6? 00:00:00 kworker / 0: 0H-kblockd

8? 00:00:00 mm_percpu_wq

9? 00:00:42 ksoftirqd / 0

10? 00:03:46 rcu_sched

eleven ? 00:00:00 rcu_bh

12? 00:00:01 migration / 0

14? 00:00:00 cpuhp / 0

fifteen ? 00:00:00 cpuhp / 1

...

As can be seen in this way, it will be possible to easily see all the processes running in the operating system.

Continuing to perform a small learning test we can run bash in the background by executing:

bash &

It would display something as follows:

[1] 14368

This is the process pid then it runs:

ps

Executing the above command shows:

PID TTY TIME CMD

11875 pts / 1 00:00:00 bash

14368 pts / 1 00:00:00 bash

14426 pts / 1 00:00:00 ps

Observing the running process we only have to kill it in the kill command as follows:

kill -9 14368

Then it runs:

ps

Executing the above command shows:

PID TTY TIME CMD

11875 pts / 1 00:00:00 bash

14543 pts / 1 00:00:00 ps

[1] + Done (killed) bash

And with this, a mini process management practice with GNU / Linux could be carried out.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.