Methods of payment Abuse

How to View Running Services in Linux

03.09.2025, 10:27

Linux provides a wide range of system services (such as process management, login, syslog, cron, and more), as well as network services (remote access, email, printing, web hosting, data storage, file transfer, DNS, DHCP, and so on).

In essence, a service is a process or a group of processes that run continuously in the background, waiting for requests—most often from clients.

Linux offers several ways to manage services: start, stop, restart, or enable them to launch automatically at boot. Nearly all modern distributions rely on the same process manager — systemd.

What is systemd?

Systemd is a system and service manager for Linux that replaced the old init system. It remains compatible with legacy SysV and LSB scripts. The main tool to work with systemd is the systemctl command.

Why check the list of running services?

This can be useful for:

→ monitoring resource usage;

→ diagnosing performance issues;

→ verifying that critical services are actually active;

→ improving security and system stability.


Systemd makes this task much easier: just a few commands let you list, check, and if necessary restart services.

Viewing services with systemctl

If you run systemctl with no arguments, it shows all systemd services along with their statuses.

Examples:

All loaded services:

systemctl list-units --type=service


Only active ones:

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

Only currently running:

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


Making life easier: create an alias

If you often use long commands, you can add an alias to your ~/.bashrc:
alias running_services='systemctl list-units --type=service --state=running'

Now, typing running_services will quickly display the list of running services.

How to find out which port a service uses

You can check ports with netstat or ss. For example:

netstat -ltup | grep zabbix_agentd
ss -ltup | grep zabbix_agentd

Flags:
→ -l — listening sockets

→ -t — TCP

→ -u — UDP

→ -n — show port numbers

→ -p — show process name

Checking open ports in the firewall

Depending on your distribution:

firewall-cmd --list-services   # for FirewallD
firewall-cmd --list-ports
sudo ufw status                # for UFW

Automatic service monitoring

Add this to your crontab:

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

This way you’ll always have a fresh log at /tmp/running_services.log.

Automatic restart on failure

To make a service restart automatically, edit its unit file:

systemctl edit apache2

Then add:

[Service]
Restart=always
RestartSec=5s

Reload and restart to apply changes:

systemctl daemon-reload
systemctl restart apache2

Hardening services

For better security, you can add options like these to a service configuration:

[Service]
NoNewPrivileges=true
ProtectSystem=full
PrivateTmp=true

These settings restrict process privileges and access to the system.