How to List All Running Services Under Systemd in Linux

Introduction

Systemd is a system and service manager for Linux operating systems. It provides a standard process for controlling what programs run when a Linux system boots up. Systemd also provides a way to list all running services under it. This tutorial will explain how to list all running services under systemd in Linux. It will cover the different commands and options available to list services, as well as how to interpret the output.

How to List All Running Services Under Systemd in Linux

1. To list all running services under Systemd in Linux, open a terminal window and type the following command:

systemctl list-units –type=service –state=running

2. This command will list all running services under Systemd in Linux. The output will include the service name, description, and status.

3. To list all services, regardless of their status, use the following command:

systemctl list-units –type=service

4. To list all services with a specific name, use the following command:

systemctl list-units –type=service –name=

5. To list all services with a specific status, use the following command:

systemctl list-units –type=service –state=

Replace and with the appropriate values.
[ad_1]

Linux systems provide a variety of system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, e-mail, printers, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address assignment (using DHCP), and much more).

Technically, a service is a process or group of processes (commonly known as daemons) running continuously in the background, waiting for requests to come in (especially from clients).

Linux supports different ways to manage (start, stop, restart, enable auto-start at system boot, etc.) services, typically through a process or service manager. Most if not all modern Linux distributions now use the same process manager: systemd.

Systemd is a system and service manager for Linux; a drop-in replacement for the init process, which is compatible with SysV and LSB init scripts, and the systemctl command is the primary tool to manage systemd.

In this guide, we will demonstrate how to list all running services under systemd in Linux.

Listing Running Services Under SystemD in Linux

When you run the systemctl command without any arguments, it will display a list of all loaded systemd units (read the systemd documentation for more information about systemd units) including services, showing their status (whether active or not).

# systemctl 
List Systemctl Units in Linux
List Systemctl Units in Linux

To list all loaded services on your system (whether active; running, exited, or failed, use the list-units subcommand and --type switch with a value of service.

# systemctl list-units --type=service
OR
# systemctl --type=service
List All Services Under Systemd
List All Services Under Systemd

And to list all loaded but active services, both running and those that have exited, you can add the --state option with a value of active, as follows.

# systemctl list-units --type=service --state=active
OR
# systemctl --type=service --state=active
List All Active Running Services in Systemd
List All Active Running Services in Systemd

But to get a quick glance at all running services (i.e. all loaded and actively running services), run the following command.

# systemctl list-units --type=service --state=running 
OR
# systemctl --type=service --state=running
List Running Services in Systemd
List Running Services in Systemd

If you frequently use the previous command, you can create an alias command in your ~/.bashrc file as shown, to easily invoke it.

# vim ~/.bashrc

Then add the following line under the list of aliases as shown in the screenshot.

alias running_services="systemctl list-units  --type=service  --state=running"
Create a Alias for Long Command
Create an Alias for Long Command

Save the changes in the file and close it. And from now onwards, use the “running_services” command to view a list of all loaded, actively running services on your server.

# running_services	#use the Tab completion 
View All Running Services
View All Running Services

Besides, an important aspect of services is the port they use. To determine the port a daemon process is listening on, you can use the netstat or ss command as shown.

Where the flag -l means print all listening sockets, -t displays all TCP connections, -u shows all UDP connections, -n means print numeric port numbers (instead of application names) and -p means show the application name.

# netstat -ltup | grep zabbix_agentd
OR
# ss -ltup | grep zabbix_agentd

The fifth column shows the socket: Local Address:Port. In this case, the process zabbix_agentd is listening on port 10050.

Determine Process Port
Determine Process Port

Also, if your server has a firewall service running, which controls how to block or allow traffic to or from selected services or ports, you can list services or ports that have been opened in the firewall, using the firewall-cmd or ufw command (depending on the Linux distributions you are using) as shown.

# firewall-cmd --list-services   [FirewallD]
# firewall-cmd --list-ports

$ sudo ufw status     [UFW Firewall]
List Open Services and Ports on Firewall
List Open Services and Ports on the Firewall

That’s all for now! In this guide, we demonstrated how to view running services under systemd in Linux. We also covered how to check the port service is listening on and how to view services or ports opened in the system firewall.

Do you have any additions to make or questions? If yes, reach us using the comment form below.

[ad_2]

How to List All Running Services Under Systemd in Linux

Systemd is a system and service manager for Linux operating systems. It provides a standard process for controlling what programs run when a Linux system boots up. Systemd also provides a way to list all running services under it.

Step 1: Check if Systemd is Running

Before you can list all running services under Systemd, you need to make sure that Systemd is running on your system. To do this, open a terminal window and type the following command:

systemctl status

If Systemd is running, you should see a message that says “active (running)”. If Systemd is not running, you will need to start it before you can list all running services.

Step 2: List All Running Services

Once you have confirmed that Systemd is running, you can list all running services by typing the following command in the terminal window:

systemctl list-units --type=service --state=running

This command will list all services that are currently running under Systemd. The output will look something like this:

UNIT                            LOAD   ACTIVE SUB    DESCRIPTION
sshd.service                     loaded active running OpenSSH Daemon
dbus.service                     loaded active running D-Bus System Message Bus
cron.service                     loaded active running Regular background program processing daemon

The output will list the name of the service, its status (loaded, active, or running), and a brief description of what the service does.

Step 3: Stop a Service

If you want to stop a service that is currently running, you can use the following command:

systemctl stop [service name]

For example, if you wanted to stop the SSH service, you would type the following command:

systemctl stop sshd.service

This command will stop the SSH service and it will no longer be listed when you run the command to list all running services.

Conclusion

Systemd is a powerful system and service manager for Linux operating systems. It provides a standard process for controlling what programs run when a Linux system boots up. You can use the Systemd commands to list all running services and to stop a service if needed.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00