Operations 6 min read

Mastering systemd: List, filter, and manage Linux services with simple commands

This guide explains how to use systemd’s systemctl tool to list all loaded services, filter by active or running state, create a handy alias for quick access, check which ports services listen on, and view firewall‑allowed services on a Linux server.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Mastering systemd: List, filter, and manage Linux services with simple commands

Overview of Linux services and systemd

Linux provides a variety of system and network services that run as background daemons. Modern distributions use systemd as the unified service manager, and the systemctl command is the primary interface for controlling these services.

Listing all loaded services

Running systemctl without arguments displays every loaded unit, including services, and shows each unit’s current state. # systemctl To list only service units, use the --type=service option.

# systemctl list-units --type=service

Filtering by service state

To see only active (loaded) services, add --state=active. For services that are currently running, use --state=running.

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

Creating a convenient alias

For frequent use, add an alias to ~/.bashrc: # vim ~/.bashrc Append the following line:

alias running_services='systemctl list-units --type=service --state=running'

After saving the file, the new command running_services instantly lists all loaded, running services.

Checking which ports services listen on

Use netstat or ss to display listening sockets. The -l flag shows listening sockets, -t for TCP, -u for UDP, -n for numeric ports, and -p to reveal the owning process.

# netstat -ltup | grep mysqld.service
# ss -ltup | grep zabbix_agentd

The output’s fifth column contains the local address and port; for example, zabbix_agentd listens on port 10050.

Viewing firewall‑allowed services and ports

Depending on the distribution, use firewall-cmd (Firewalld) or ufw to list services and ports permitted through the firewall.

# firewall-cmd --list-services   [FirewallD]
# firewall-cmd --list-ports
$ sudo ufw status                [UFW Firewall]

Summary

We demonstrated how to list and filter systemd services, create a shortcut alias for quickly viewing running services, inspect the ports those services use, and query firewall rules that affect them. These techniques help Linux administrators monitor and manage server workloads efficiently.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

network portsService Managementsystemdsystemctlbash alias
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.