search
HomeSystem TutorialLINUXHow to List All Running Services Under Systemd in Linux

Linux systems provide various system services (such as process management, login , syslog, cron, etc.) and network services (such as remote login, email, printer, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address allocation (using DHCP ), etc.).

Technically, a service is a process or group of process (often called a daemon ) that runs continuously in the background, waiting for incoming requests (especially from the client).

Linux supports different ways to manage services (start, stop, restart, enable automatic startup at system startup, etc.), usually through a process or service manager. Almost all modern Linux distributions now use the same process manager: systemd .

What is Systemd?

Systemd is the system and service manager of Linux; it is a direct replacement for the init process, compatible with SysV and LSB init scripts, and the systemctl command is the main tool for managing systemd .

Why list services running in Linux?

It is important to know which services are running on your Linux system because:

  • Monitor resource utilization
  • Troubleshoot performance issues
  • Ensure critical services are active
  • Optimize system performance and security

Systemd simplifies service management using powerful systemctl commands (also known as basic commands), making it easy to list, monitor, and manage active services.

In this guide, we will demonstrate the process of listing all running services under Systemd in Linux, providing a comprehensive walkthrough for users of all experience levels.

List the running services under SystemD in Linux

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

 <code># systemctl</code>

How to List All Running Services Under Systemd in Linux

List all loaded services in Linux

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

 <code># systemctl list-units --type=service OR # systemctl --type=service</code>

How to List All Running Services Under Systemd in Linux

List only active services in Linux

To list all loaded but active services, including running and exited services, you can add the --state option with the value active as shown below.

 <code># systemctl list-units --type=service --state=active OR # systemctl --type=service --state=active</code>

How to List All Running Services Under Systemd in Linux

Use systemctl to list running services in Linux

However, to quickly see all running services (i.e. all loaded and actively running services), run the following command.

 <code># systemctl list-units --type=service --state=running OR # systemctl --type=service --state=running</code>

How to List All Running Services Under Systemd in Linux

Let's explore the key terms related to Systemd units and their state:

  • Unit – A unit can be a service, socket, device, or various other entities.
  • Load – It indicates whether the unit is loaded. The cell can be loaded, but not necessarily active.
  • Active – It shows if the unit is running actively, or if it is having problems and is in a failed or inactive state.
  • SUB – It provides more details about unit-specific status. For a service, it may indicate whether the service is running (running), stopped (exited), or encountered a problem (failed).
  • Description – It helps users identify and understand the purpose of the unit without delving into detailed configuration files.

Create an alias for the systemctl command

If you use previous commands frequently, you can create an alias command in the ~/.bashrc file as shown to make it easy to call it.

 <code># vim ~/.bashrc</code>

Then, add the following line under the alias list as shown in the screenshot.

 <code>alias running_services='systemctl list-units  --type=service  --state=running'</code>

How to List All Running Services Under Systemd in Linux

Save changes in the file and close it. From now on, use the " running_services " command to view all loaded and actively running services on the server.

 <code># running_services #use the Tab completion</code>

How to List All Running Services Under Systemd in Linux

Find the port that the service is using

Furthermore, another important aspect of services is the ports they use. To determine which port the daemon is listening on, you can use the netstat or ss command as shown below.

Where the flag -l means printing all listening sockets, -t shows all TCP connections, -u shows all UDP connections, -n means printing the digital port number (not the application name), -p means displaying the application name.

 <code>netstat -ltup | grep zabbix_agentd OR ss -ltup | grep zabbix_agentd</code>

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

How to List All Running Services Under Systemd in Linux

List open firewall services and ports

Additionally, if your server is running a firewall service that controls how to block or allow data flow to a selected service or port, you can use the firewall-cmd or ufw command (depending on the Linux distribution you are using) to list the services or ports that have been opened in the firewall, as shown below.

 <code>firewall-cmd --list-services [FirewallD] firewall-cmd --list-ports sudo ufw status [UFW Firewall]</code>

How to List All Running Services Under Systemd in Linux

Automating service monitoring in Linux

Manually checking for running services can be cumbersome, especially on production servers. Automating this process ensures that you are always aware of changes in service status without manual checking.

Check running services every 5 minutes using Cron jobs

A cron job is a scheduled task in Linux that runs at specific intervals. You can use it to log running services regularly and view them later in the event of a failure or unexpected shutdown.

 <code>crontab -e</code>

Add this line to record the running service every 5 minutes.

 <code>*/5 * * * * systemctl list-units --type=service --state=running > /tmp/running_services.log</code>

The output will be saved in the /tmp/running_services.log file, you can check the latest recorded services using the following command:

 <code>cat /tmp/running_services.log OR tail -f /tmp/running_services.log</code>

Restart the service when the service fails

By default, if the service crashes or stops unexpectedly, it will not automatically restart unless explicitly configured. To ensure that the service restarts on failure, you can modify its systemd service unit file.

For example, edit the service configuration using the following command (replace apache2 with the actual service name you want to restart automatically):

 <code>systemctl edit apache2</code>

After entering the editor, add the following lines.

 <code>[Service] Restart=always RestartSec=5s</code>

Now reload systemd to apply the changes.

 <code>systemctl daemon-reload</code>

Then restart the service to make sure it picks up the new settings

 <code>systemctl restart apache2</code>

Confirm that systemd is set to automatically restart the service.

 <code>systemctl show apache2 --property=Restart</code>
in conclusion

That's it now! In this guide, we demonstrate how to view the running services under systemd in Linux. We also covered how to check the ports the service is listening on and how to view the service or port that is open in the system firewall.

Do you have any supplements or questions? If so, please contact us using the comment form below.

The above is the detailed content of How to List All Running Services Under Systemd in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Automatically Restart a Failed Service in LinuxHow to Automatically Restart a Failed Service in LinuxApr 28, 2025 am 09:39 AM

This guide details how to configure automatic service restarts in Linux using systemd, enhancing system reliability and minimizing downtime. System administrators often rely on this functionality to ensure critical services, such as web servers (Apa

10 Hidden Linux Commands Every Sysadmin Should Know10 Hidden Linux Commands Every Sysadmin Should KnowApr 28, 2025 am 09:35 AM

As Linux users, we often rely on commonly used commands ls, grep, awk, sed and find to complete the work. But Linux has a large number of lesser-known commands that can save time, automate tasks and simplify workflows. This article will explore some underrated but powerful Linux commands that deserve more attention. rename – efficient batch rename files The rename command is the savior when you need to rename multiple files at once. Without using loops containing mv, rename allows you to easily apply complex renaming patterns. Change all .txt files to .log. rename 's/\.txt$/\.log/' *

How to List All Running Services Under Systemd in LinuxHow to List All Running Services Under Systemd in LinuxApr 28, 2025 am 09:29 AM

Linux systems provide various system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, email, printer, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address allocation (using DHCP), and so on). Technically, a service is a process or group of process (usually known as a daemon) that runs continuously in the background, waiting for incoming requests (especially from the client). Linux supports different ways to manage services (start, stop, restart, enable automatic startup at system startup, etc.), usually through a process or service manager. Almost all modern Linux distributions now use the same

CrossOver 25: Run Windows Software and Games on LinuxCrossOver 25: Run Windows Software and Games on LinuxApr 28, 2025 am 09:27 AM

Run Windows Software and Games on Linux with CrossOver 25 Running Windows applications and games on Linux is now easier than ever, thanks to CrossOver 25 from CodeWeavers. This commercial software solution lets Linux users run a wide variety of Wind

pCloud - The Most Secure Cloud Storage [50% Off Offer]pCloud - The Most Secure Cloud Storage [50% Off Offer]Apr 28, 2025 am 09:26 AM

Secure Your Data with pCloud: A Comprehensive Guide to Linux Installation pCloud, a leading secure cloud storage service, provides a robust platform for managing your files and data. This guide details the installation process on Linux systems. About

MangoHud - Monitor FPS, CPU & GPU Usage in Linux GamesMangoHud - Monitor FPS, CPU & GPU Usage in Linux GamesApr 28, 2025 am 09:25 AM

MangoHud: A powerful tool for real-time monitoring of Linux gaming performance MangoHud is a powerful and lightweight tool designed for gamers, developers, and anyone who wants to monitor system performance in real time. It acts as an overlay for Vulkan and OpenGL applications, displaying important information such as FPS, CPU and GPU usage, temperature, etc. This article will explore the functions, working principles and usage of MangoHud, and provide step-by-step instructions for installing and configuring MangoHud on Linux systems. What is MangoHud? MangoHud is an open source project available on GitHub and aims to provide a simple and customizable way to monitor

5 Must-Know Linux Command Line Archive Tools – Part 15 Must-Know Linux Command Line Archive Tools – Part 1Apr 28, 2025 am 09:23 AM

Managing archived files is a common task in Linux. This article, the first of a two-part series, explores five powerful command-line archive tools, detailing their features and usage with examples. 1. The tar Command: A Versatile Archiving Utility t

Top 7 Tools to Compare Files in Linux (with Examples)Top 7 Tools to Compare Files in Linux (with Examples)Apr 28, 2025 am 09:21 AM

This guide explores various methods for comparing text files in Linux, a crucial task for system administrators and developers. We'll cover command-line tools and visual diff tools, highlighting their strengths and appropriate use cases. Let's assum

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.