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.
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=serviceFiltering 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=runningCreating 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_agentdThe 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
