The site already has a few articles about Linux processes, detailing how to manage them or how to complete one or a group of processes, but that’s not all. To properly manage the processes and to navigate them you need to learn how to analyze the list of Linux processes to understand what each item is and why you need it.
In this article we’ll look at how to see list of processes in various ways, let us examine what are the processes, why it happens and what to do with it.
- The list of processes in Linux
- 1. The ps utility
- 2. The top utility
- 3. Utility htop
- 4. The Program Gnome Monitor
- 5. Utility atop
The list of processes in Linux
I won’t go into detail about each command that can be used to view the list of running processes, instead, we go through the main tools for this task, consider how to list threads of a process display the processes running on a particular core, and also how to find hidden processes. But first you have to understand the terms.
- Process – if to speak simple words, it is a program and its data are loaded in the computer memory;
- Child process – processes can start other processes to perform concurrent tasks or other purposes such processes are called children. For them there is a separate area in memory;
- Flow – the flow differs from the process that uses the same memory, data and file handles that the process in which it was created.
1. The ps utility
The easiest way to see list of processes running in the current command shell, use the ps command without any parameters:
But if you are interested in it. To view all processes, add the option -e, and for the most information – option -F:
Here the value of the fixed columns in the output of utilities:
- UID – the username on whose behalf the process runs;
- PID – the identifier of the user;
- PPID – the process ID of the parent user;
- C – use of resources of CPU, in percentage;
- SZ – size of the process;
- RSS is the real size of process in memory;
- PSR – core processor running the process;
- STIME – the time the process was started;
- TTY – if a process is bound to the terminal, here you will output its number.
- TIME – total execution time of the process (user + system);
- CMD – the command which launched the process, if the program cannot read the arguments of the process, it will be shown in square brackets;
To view a list of processes in a tree view, and understand what process has any child processes, run the following command:
To view the list of processes with streams, use the option -L:
There will also be two additional columns:
- LWP Is an acronym LightWeight Proccess. The thread identifier;
- NLWP the number of threads to this process.
To view a list of processes a specific user, for example, sergiy, use the option -u:
Now let’s move on to other more interesting, interactive tools.
2. The top utility
The top utility is not shipped with the system so you have to install it. To do this in Ubuntu, run:
sudo apt install top
The program allows you to interactively view the list of running Linux processes. To list the Linux process, run the command:
Column, which displays the program is very similar to ps:
- PID – the process identifier;
- USER – the user name on whose behalf the process is running;
- PR – scheduler priority set for the process;
- NI – recommended priority of the process. This value can be changed, may not coincide with the actual priority of the scheduler;
- VIRT – whatever is in memory is used or reserved for use;
- RES – everything is in memory, and refers to the process. Stands for Resident Memory Size, in kilobytes;
- SHR – memory part of RES occupied resources available for use by other processes. Stands for – Shared Memory Size.
- S – process status: D – queued, R – running, S – sleep, T – stopped, t – stopped by a debugger, Z – zombie;
- %CPU – percentage of CPU utilization;
- %MEM – the percentage of resource usage the RAM based on column RES;
- TIME – total CPU time that process has used since the launch;
- COMAND – command with which the process was started.
To make the program output a colour, press Z:
To display a tree of processes in Linux, press Shift+V:
To display flow hit Shift + H:
If you are not standard fields with information about the processes, you can press Shift + F and select the additional fields that need to display. To select or delete a field, use the spacebar:
3. Utility htop
It is even more powerful utility to view running processes in Linux. To use it much easier. Here are not only hot keys, but the mouse control. And it removes all color, so look at the data much nicer. To install the program follow:
sudo apt install htop
To run, run in terminal:
Speakers that you will see in the output, similar to those available in top, so I will not consider them here separately. To configure output press F2, then go to Display Options:
Here we must note Tree view to list processes in a tree view and unmark the items Hide threads… to display threads. Here is how the threads are user-space threads userland processand the threads kernel space – kernel threads. Now all this will be displayed:
To configure what columns will be displayed, select Columns:
Here you can choose which columns to display and which not, and can also customize their order.
4. The Program Gnome Monitor
You can watch running processes in terminal, but in a graphical interface. For this purpose you can use the Gnome Monitor. She has much less features compared to ps, but it has a graphical interface. You can run the program from the main menu of the system:
By default, the utility displays only the processes of the current user. If you want to get all the processes click on the icon of a sandwich, and select All the process:
Now the program displays all running processes in Linux system. Here you can search by processes, terminate them and more. But flows and process tree of the program does not show.
5. Utility atop
This program also allows you to view the processes in Linux , but in a slightly different way. The utility was more interested in how much of a particular process consumes system resources. Utility even can show the consumption processes, disk throughput and network, but that it needed a special patch to the kernel. To install the program in Ubuntu, run:
sudo apt install atop
Then run it:
Here’s the main column that displays utility and their values:
- PID – the process identifier;
- CID – the ID of the container that is used for Docker containers;
- SYSCPU is the time spent by the process executing in the kernel space;
- USRCPU – time spent by the process executing in user space;
- VGROW – the increase in memory usage column VIRT in recent period;
- RGROW is the increase in memory usage column the RSS for the most recent period;
- ST – the status of the process, N – new, E – complete, S and s – process is terminated forcibly by a signal;
- EXC – exit code or code signal, which process was completed;
- THR – total number of threads in this process;
- S – the status of the process as described for the top;
- CPUNR – core number of the processor running the main thread process;
- CPU – utilization percent of CPU resources;
- CMD – the command invoking the program;
- MEM – percentage of memory usage;
In order to enable the display of process threads, press y:
To view information about the memory, press m if you want to go back, hit g:
In this article we reviewed the most basic ways to see the list of processes in Linux, as you can see there are simple ways, but there are more complex and informative. What methods do you use most often? Write in the comments!