How to list all running services in Linux using command line

Linux-based operating systems, like all other operating systems, have processes and services that run while the machine is running. They range from various operating system services to command line to various services / daemons designed to keep the system running smoothly. Most of the services are vital for the normal operation of a process, ranging from support services to special services designed to handle input, improve performance, offload resources, etc. Processes are also the backbone of the basic functions of a computer, which makes it important to have resources for everyone.

However, it can happen that a service can run without your knowledge, use up system resources and even make your system vulnerable if security measures are not taken into account. Because of the possible cases like these, it is good to know how to check for and handle such cases, and also be able to keep track of what processes and services are running on your computer at any given moment.

In this article, we will go over several ways to list / display all running services and processes on a Linux server or machine, and also take a look at some useful commands to help you find and manage these processes and services.

‘Service’ command line tool

The service command comes preinstalled with almost every Linux distribution. Although the main purpose is to start and stop scripts and create processes, “service” can also be used to see which services are running or stopped at any time. Using a simple command, we are provided with a complete list of services:

service --status-all

When you run this, the same output appears:

[ + ] apache-htcacheclean
[ + ] apache2
[ + ] apparmor
[ + ] bind9
[ - ] bluetooth
[ - ] bootmisc.sh
[ - ] cgmanager
[ - ] cgproxy
[ - ] checkfs.sh
[ - ] checkroot-bootclean.sh
[ - ] checkroot.sh
(continued)

How to list all running services in Linux from command line

As you can see, the list of services is provided as output with a character to the left of the service name. “+” Means the service is running, “-” means it is stopped, and “?” means that the status is currently unknown. When used in conjunction with a search tool such as “grep”, it is very easy to find specific services that are running. Then you can check the status based on the process by entering the status command for a specific process:

service <service name> status

It then outputs a bunch of information related to that particular service, including the location of the process, whether the service is running or even the last few lines of the log file from the service.

PS

PS is a preinstalled utility for displaying information and information about processes. It’s a simple, fast tool designed to get results quickly without fuss. With one simple command, we can list a detailed list of currently running processes:

ps -aux

You can use this in conjunction with the less command to further improve readability. When executing this command, we are given detailed information about each running process. You can also use the grep command to narrow down the results to a specific process name, process ID, etc.

Command line tool ‘top’

“Top” is a built-in tool designed to provide an overview of all the processes and services currently running on your computer. It is included with Debian and RedHat based distributions and offers many features to help you understand what’s going on on your server. You can start at the top by simply drawing the top at the command line. This is how it should look:

top - 03:29:24 up 53 min, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 58 total, 1 running, 57 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.2 us, 0.0 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 2097152 total, 1025376 free, 504424 used, 567352 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 1485816 avail Mem
PID  USER PR NI VIRT   RES  SHR S %CPU %MEM TIME+  COMMAND
1073 root 20 0  128404 1672  888 S 0.3 0.1 0:00.45 screen
3160 root 20 0  157900 2156 1516 R 0.3 0.1 0:00.06 top
   1 root 20 0  129484 3716 2412 S 0.0 0.2 0:03.03 systemd
   2 root 20 0       0    0    0 S 0.0 0.0 0:00.00 kthreadd/2306
   3 root 20 0       0    0    0 S 0.0 0.0 0:00.00 khelper/2306
  57 root 20 0   39176 2816 2492 S 0.0 0.1 0:00.53 systemd-journal
  63 root 20 0   42624 1740 1292 S 0.0 0.1 0:00.01 systemd-udevd
(continued)

How to list all running services in Linux from command lineIt might look a little cluttered, but most of this information is very helpful. For example, we can see how long the system has been running, the load average, how many users are logged in, how many processes (tasks) are running, sleeping, etc., as well as information about the amount of memory we have and are available on the server. Top goes into even more detail, down to the process-specific level. Each column displays a specific value that correlates with the process that is running. We can see who owns a process, how much memory it is using, how much processor is used, the command name and process ID that is unique to that process, and helps us identify it if there is more than one of the same process. Using all this information, we can see exactly what each process is doing and how many resources each process is using.

HTOP

Htop is very similar to “top” in terms of its core features and functionality. It is usually not included in the default operating system installation, however it is available for most, if not all Linux distributions through their pre-installed software repositories. Like top, htop allows the user to view detailed information about each process as well as keep an eye on the system itself. However, htop allows for much more precise control over the information you display, and it also offers a set of utilities that can be applied to processes.

For example, through htop, you can adjust the subtlety (priority) of the process, kill it with different strength levels, etc. There is also a sorting that makes it easier to see only the information that is important to you. Process selection is possible with a space, making it easier to track and trace a specific process (or processes, since you can select more than one at a time). And with the search function, it’s even easier to check and pay attention to specific processes. Htop even has a bar graph that represents the various system resources, allowing you to easily see how much CPU or RAM is being allocated.

Here’s an example of what htop looks like:

1  [                                                                0.0%] Tasks: 35, 113 thr; 1 running
2  [||                                                              1.3%] Load average: 0.01 0.05 0.01
Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 799M/2.00G] Uptime: 4 days, 22:53:28
Swp[                                                               0K/0K]

  PID   USER  PRI NI   VIRT  RES  SHR S CPU%  MEM%   TIME+  Command
 9357  mysql   20  0  1625M 196M 1944 S 0.7    9.6  4:54.66 /usr/sbin/mysqld
26708   root   20  0  26520 4092 1464 R 0.7    0.2  0:00.66 htop
    1   root   20  0 129484 3716 2412 S 0.0    0.2  0:03.03 systemd
(continued)

With the bars at the top, it’s easy to see how your system works with a single glance, as well as the customizable details available below them.

How to list all running services in Linux from command lineUsing any of these tools, you can easily find accurate information about your services and processes.

Related Posts