How to Manage Processes in Linux

How to Manage Processes in Linux

We’ll show you, How to Manage Processes in Linux. A process is the abstraction used by the Linux operating system to represent a running program. Each process in Linux consists of an address space and a set of data structures within the server kernel. The address space contains the code and libraries that the process is executing, the process variables, its stacks, and different additional information needed by the kernel while the process is running.


PID is a unique ID number named and it is assigned by the kernel to every process. PIDs are assigned in order as processes are created.

UID is a user identification number of the person who created it.

The EUID is the ‘effective’ user ID, used to determine what resources and files a process has permission to access at any given moment. In general, the UID and EUID are the same, except for the programs that are setuid.

The GID is the group identification number of a process. The EGID is related to the GID in the same way that the EUID is related to the UID. In short, a process can be a member of many groups at once.

Listed below are some basic commands to manage processes in Linux:

1. ps Command to Manage Processes in Linux

It is one of the essential Linux system administrator commands used for monitoring processes. While different versions of ps differ in their arguments and display, they all deliver the same information. The output of the ps command can show the PID, UID, priority, and control terminal of processes. It also gives information about how much CPU time it has consumed, how much memory a process is using, and its current status (state).

Process states codes:

R – running – the process is running/can be executed.
D – uninterruptible sleep
S – interruptible sleep – the process is waiting for some event to complete
T – Traced or stopped
Z – Zombie – defunct process, a terminated process but still hanging around in kernel process table because the parent of this process has still not fetched the termination status of this process.

Here’s an example of ps aux output on a CentOS 7 VPS with cPanel installed on it:

 # ps aux

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1 129180  3584 ?        Ss   Mar16   1:44 init -z
root         2  0.0  0.0      0     0 ?        S    Mar16   0:00 [kthreadd/2172]
root         3  0.0  0.0      0     0 ?        S    Mar16   0:00 [khelper/2172]
root        59  0.0  0.4  36920  8508 ?        Ss   Mar16   0:09 /usr/lib/systemd/systemd-journald
root        60  0.0  0.0  41880  1680 ?        Ss   Mar16   0:00 /usr/lib/systemd/systemd-udevd
dbus        96  0.0  0.0  24348  1712 ?        Ss   Mar16   0:07 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root        97  0.0  0.1 148184  3168 ?        Ss   Mar16   0:00 pure-ftpd (SERVER)
mysql       99  0.0  0.0 113204  1588 ?        Ss   Mar16   0:00 /bin/sh /usr/bin/mysqld_safe
root       103  0.0  0.0  22232  1576 ?        Ss   Mar16   0:03 /usr/lib/systemd/systemd-logind
root       108  0.0  0.0  14536  1624 ?        Ss   Mar16   0:01 /usr/sbin/dovecot -F -c /etc/dovecot/dovecot.conf
root       115  0.0  0.0 145660  1920 ?        Ss   Mar16   0:00 /usr/sbin/pure-authd -s /var/run/ftpd.sock -r /usr/local/cpanel/bin/pureauth
root       121  0.0  0.0  24236  2072 ?        Ss   Mar16   0:00 /usr/sbin/smartd -n -q never
nscd       126  0.0  0.1 1059752 2116 ?        Ssl  Mar16   0:05 /usr/sbin/nscd
root       132  0.0  0.0  82476  1332 ?        Ss   Mar16   0:00 /usr/sbin/sshd
root       133  0.0  0.3 308544  7972 ?        Ssl  Mar16   0:00 /usr/sbin/rsyslogd -n
root       146  0.0  0.0 124308  1532 ?        Ss   Mar16   0:00 /usr/sbin/crond -n
root       148  0.0  0.0   4488   736 tty2     Ss+  Mar16   0:00 /sbin/agetty --noclear tty2 linux
root       149  0.0  0.0 108076   776 tty1     Ss+  Mar16   0:00 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 vt220
root       150  0.0  0.0  24096   980 ?        Ss   Mar16   0:00 /usr/sbin/atd -f
dovenull   159  0.0  0.1  43392  3588 ?        S    Mar16   0:00 dovecot/pop3-login
dovenull   160  0.0  0.1  43536  3844 ?        S    Mar16   0:00 dovecot/imap-login
dovecot    161  0.0  0.0   9568  1192 ?        S    Mar16   0:00 dovecot/anvil
root       162  0.0  0.0   9700  1376 ?        S    Mar16   0:00 dovecot/log
dovenull   164  0.0  0.1  43536  3880 ?        S    Mar16   0:00 dovecot/pop3-login
dovenull   165  0.0  0.1  43400  3608 ?        S    Mar16   0:00 dovecot/imap-login
root       170  0.0  0.1  10908  2336 ?        S    Mar16   0:01 dovecot/config
root       295  0.0  1.1 165248 23448 ?        S    Mar16   0:06 queueprocd - wait to process a task
mysql      407  0.0  2.2 706500 47848 ?        Sl   Mar16   2:20 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/lib/mysql/vps.err --open-files-limit=10000 --pid-file=/var/li
root       410  0.0  0.9 501748 20392 ?        Ss   Mar16   0:05 /usr/sbin/httpd -k start
root       412  0.0  0.7  55208 15124 ?        S    Mar16   0:00 /usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/bin/leechprotect
nobody     429  0.0  0.5 502120 10552 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
nobody     430  0.0  0.5 502024 10528 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
nobody     431  0.0  0.5 502024 10536 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
nobody     432  0.0  0.5 502024 10568 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
nobody     433  0.0  0.5 502024 10580 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
root       582  0.0  0.1  26848  3212 ?        S    Mar16   0:02 cpsrvd (SSL) - dormant mode - accepting  --llu=1489749164 --listen=10,11,12,4,5,6,7,8,9
named      596  0.0  1.0 248500 20988 ?        Ssl  Mar16   0:47 /usr/sbin/named -u named
root       636  0.0  0.1 130088  2620 ?        Ss   Mar16   0:00 dnsadmin - dormant mode                    --listen=3
root       639  0.0  0.1 130448  2212 ?        S    Mar16   0:00 cpdavd - accepting connections on 2077, 2078, 2079, and 2080 (dormant)
root       641  0.0  0.1 129796  2368 ?        S    Mar16   0:04 cPhulkd - processor - dormant mode - acce --listen=3
root       644  0.0  0.1  26496  2384 ?        SN   Mar16   0:00 cpanellogd - sleeping for logs
root       656  0.0  1.1 104032 24496 ?        S    Mar16   0:03 tailwatchd
mailnull   818  0.0  0.2  77552  4672 ?        Ss   Mar16   0:00 /usr/sbin/exim -ps -bd -q1h -oP /var/spool/exim/exim-daemon.pid
nobody    2660  0.0  0.4 502016 10396 ?        S    Mar16   0:00 /usr/sbin/httpd -k start
root      7500  0.9  4.7 225200 100212 ?       Ss   Mar16  29:01 /usr/local/cpanel/3rdparty/perl/524/bin/perl -T -w /usr/local/cpanel/3rdparty/bin/spamd --max-spare=1 --max-children=3 --allowed-ips=127.0.0.1,::1 --pidfile=/var/run/spamd.
root     17897  0.2  4.6 225880 97464 ?        S    09:37   0:00 spamd child
dovecot  17905  0.0  0.1  32188  2388 ?        S    09:37   0:00 dovecot/auth
root     17937  0.0  0.0   9564  1096 ?        S    09:37   0:00 dovecot/ssl-params
root     17993  0.0  0.0 113420  1960 pts/0    Ss   09:38   0:00 -bash
root     18019  0.0  0.0 149096  1772 pts/0    R+   09:38   0:00 ps aux

A short explanation of ‘ps aux’ output:
USER – Username of the process’s owner
PID -Process ID
%CPU – Percentage of the CPU a specific process is using
%MEM – Percentage of real memory a specific process is using
VSZ – Virtual size of the process
RSS – Resident set size (number of pages in memory)
TTY – Control terminal ID
STAT – Current process status
START – Time the command started
TIME – CPU time the process has consumed
COMMAND – Command name and arguments

2. pstree – Command to Manage Processes in Linux

The pstree command displays processes in a tree format:

# pstree
systemd─┬─2*[agetty]
        ├─atd
        ├─cPhulkd - proce
        ├─cpanellogd - sl
        ├─cpdavd - accept
        ├─cpsrvd (SSL) -
        ├─crond
        ├─dbus-daemon
        ├─dnsadmin - dorm
        ├─dovecot─┬─anvil
        │         ├─config
        │         ├─2*[imap-login]
        │         ├─log
        │         ├─2*[pop3-login]
        │         └─ssl-params
        ├─exim
        ├─httpd─┬─6*[httpd]
        │       └─leechprotect
        ├─kthreadd/2172───khelper/2172
        ├─mysqld_safe───mysqld───16*[{mysqld}]
        ├─named───4*[{named}]
        ├─nscd───11*[{nscd}]
        ├─pure-authd
        ├─pure-ftpd
        ├─queueprocd - wa
        ├─rsyslogd───2*[{rsyslogd}]
        ├─smartd
        ├─spamd-dormant:
        ├─sshd
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        └─tailwatchd

3. top – Command to Manage Processes in Linux

Another way to find out what processes are running on your server:

top - 09:54:45 up 2 days,  8:44,  0 users,  load average: 0.03, 0.02, 0.00
Tasks:  50 total,   1 running,  49 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.2 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2097152 total,   316648 free,   379764 used,  1400740 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1551658 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 7500 root      20   0  225060  99964   5132 S   0.3  4.8  29:10.67 spamd
    1 root      20   0  129180   3584   2312 S   0.0  0.2   1:44.80 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd/2172
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.13 khelper/2172
   59 root      20   0   36920   8580   8272 S   0.0  0.4   0:09.38 systemd-journal
   60 root      20   0   41880   1680   1248 S   0.0  0.1   0:00.01 systemd-udevd
   96 dbus      20   0   24348   1712   1324 S   0.0  0.1   0:07.29 dbus-daemon
   97 root      20   0  148184   3168   2420 S   0.0  0.2   0:00.28 pure-ftpd
   99 mysql     20   0  113204   1588   1292 S   0.0  0.1   0:00.01 mysqld_safe
  103 root      20   0   22232   1576   1296 S   0.0  0.1   0:03.88 systemd-logind
  108 root      20   0   14536   1624   1296 S   0.0  0.1   0:01.26 dovecot
  115 root      20   0  145660   1920   1412 S   0.0  0.1   0:00.25 pure-authd
  121 root      20   0   24236   2072   1572 S   0.0  0.1   0:00.04 smartd
  126 nscd      20   0 1059752   2116   1340 S   0.0  0.1   0:05.45 nscd
  132 root      20   0   82476   1332    468 S   0.0  0.1   0:00.00 sshd
  133 root      20   0  308544   8036   7440 S   0.0  0.4   0:00.71 rsyslogd
  146 root      20   0  124308   1532    920 S   0.0  0.1   0:00.74 crond
  148 root      20   0    4488    736    636 S   0.0  0.0   0:00.00 agetty
  149 root      20   0  108076    776    676 S   0.0  0.0   0:00.00 agetty
  150 root      20   0   24096    980    792 S   0.0  0.0   0:00.00 atd
  159 dovenull  20   0   43392   3588   2712 S   0.0  0.2   0:00.05 pop3-login
  160 dovenull  20   0   43536   3844   2892 S   0.0  0.2   0:00.44 imap-login
  161 dovecot   20   0    9568   1192   1008 S   0.0  0.1   0:00.20 anvil
  162 root      20   0    9700   1376   1032 S   0.0  0.1   0:00.43 log
  164 dovenull  20   0   43536   3880   2920 S   0.0  0.2   0:00.27 pop3-login
  165 dovenull  20   0   43400   3608   2732 S   0.0  0.2   0:00.09 imap-login
  170 root      20   0   10908   2336   1180 S   0.0  0.1   0:01.85 config
  295 root      20   0  165248  23448   1896 S   0.0  1.1   0:06.60 queueprocd - wa
  407 mysql     20   0  706500  47848   6072 S   0.0  2.3   2:21.26 mysqld
  410 root      20   0  501748  20392  13044 S   0.0  1.0   0:05.61 httpd
  412 root      20   0   55208  15124   2156 S   0.0  0.7   0:00.16 leechprotect
  429 nobody    20   0  502120  10552   2908 S   0.0  0.5   0:00.42 httpd
  430 nobody    20   0  502024  10528   2904 S   0.0  0.5   0:00.47 httpd
  431 nobody    20   0  502024  10536   2912 S   0.0  0.5   0:00.45 httpd
  432 nobody    20   0  502024  10568   2940 S   0.0  0.5   0:00.41 httpd
  433 nobody    20   0  502024  10580   2960 S   0.0  0.5   0:00.52 httpd
  582 root      20   0   26848   3212   2000 S   0.0  0.2   0:02.02 cpsrvd (SSL) -
  596 named     20   0  248500  20988   2876 S   0.0  1.0   0:47.43 named
  636 root      20   0  130088   2620   1824 S   0.0  0.1   0:00.31 dnsadmin - dorm
  639 root      20   0  130448   2212    976 S   0.0  0.1   0:00.40 cpdavd - accept
  641 root      20   0  129796   2368   1752 S   0.0  0.1   0:04.45 cPhulkd - proce
  644 root      38  18   26496   2384   1376 S   0.0  0.1   0:00.60 cpanellogd - sl
  656 root      20   0  104032  24496   1604 S   0.0  1.2   0:03.73 tailwatchd
  818 mailnull  20   0   77552   4672    800 S   0.0  0.2   0:00.57 exim
 2660 nobody    20   0  502016  10396   2784 S   0.0  0.5   0:00.38 httpd
17993 root      20   0  113420   1968   1608 S   0.0  0.1   0:00.01 bash
18317 root      20   0  225888  97340   1664 S   0.0  4.6   0:00.15 spamd child
18325 dovecot   20   0   32188   2384   1804 S   0.0  0.1   0:00.01 auth
18415 root      20   0  153628   2124   1496 R   0.0  0.1   0:00.01 top

4. kill – Command to Manage Processes in Linux

The kill command is most often used to terminate a process. Kill can send any signal, but by default, it sends a TERM. kill can be used by normal users on their own processes or by root on any process.

The syntax of the kill command is:

kill [-signal] pid

where signal is the number or symbolic name of the signal to be sent and PID is the process identification number of the target process.

A kill without a signal number does not guarantee that the process will die, because the TERM signal can be caught, blocked, or ignored.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

The command ‘kill -9 pid’ ‘guarantees’ that the process will die because signal 9, KILL, cannot be caught. The killall command kills processes by name. For example, the following command kills all Dovecot processes:

$ sudo killall dovecot

This command is used to pause the current fore

5. ctrl + z – Command to Manage Processes in Linux

ground process and move it into the background:

# service spamd restart
Redirecting to /bin/systemctl restart  spamd.service
^Z
[1]+  Stopped                 service spamd restart

6. jobs – Command to Manage Processes in Linux

Display a list of current jobs running in the background:

# jobs
[1]+  Stopped                 service spamd restart

7. fg – Command to Manage Processes in Linux

This command is used to move a background process into the foreground:

# fg 1
service spamd restart

Of course, you don’t have to Manage Processes in Linux if you use one of our Fully-Managed Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to manage the server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on How to Manage Processes in Linux,  please share it with your friends on the social networks using the buttons below or simply leave a reply in the comments section. Thanks.

Leave a Comment