Home

Listing Linux services with systemctl

Services on Linux are background programs — your web server, SSH daemon, cron, etc. They can be started at boot or on demand. Knowing how to list and inspect them quickly is core to debugging anything systems-related. Most modern distros use systemd as the init system and service manager, and systemctl is the CLI you talk to it with.

Listing services

Show all loaded services (running or not):

bash
sudo systemctl list-units --type service

Sample output:

bash
  UNIT                                           LOAD   ACTIVE SUB     DESCRIPTION  accounts-daemon.service                        loaded active running Accounts Service  apparmor.service                               loaded active exited  Load AppArmor profiles  apport.service                                 loaded active exited  LSB: automatic crash report generation  atd.service                                    loaded active running Deferred execution scheduler  blk-availability.service                       loaded active exited  Availability of block devices  cloud-config.service                           loaded active exited  Apply the settings specified in cloud-config  ...

Each row shows:

To include services that aren't loaded into memory:

bash
sudo systemctl list-units --type service --all

Checking a service's status

bash
sudo systemctl status <service-name>

For example, Nginx:

bash
sudo systemctl status nginx.service
bash
 nginx.service - A high performance web server and a reverse proxy server     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)    Drop-In: /etc/systemd/system/nginx.service.d             └─limits.conf     Active: active (running) since Tue 2022-02-08 00:41:13 +03; 2 days ago   Main PID: 21684 (nginx)      Tasks: 68 (limit: 2367)     Memory: 72.6M     CGroup: /system.slice/nginx.service             ├─21684 nginx: master process /usr/sbin/nginx             ├─21685 nginx: worker process             ├─21686 nginx: worker process             └─21687 nginx: cache manager processFeb 08 00:41:13 linuxpedi systemd[1]: Starting A high performance web server and a reverse proxy server...Feb 08 00:41:13 linuxpedi nginx[21682]: nginx: the configuration file /etc/nginx/nginx.conf syntax is okFeb 08 00:41:13 linuxpedi nginx[21682]: nginx: configuration file /etc/nginx/nginx.conf test is successfulFeb 08 00:41:13 linuxpedi systemd[1]: Started A high performance web server and a reverse proxy server.

Useful fields:

Quick checks

Just want a yes/no on whether a service is running?

bash
systemctl is-active nginx.service

Other handy variants:

bash
systemctl is-enabled nginx.service     # will it start at boot?systemctl is-failed nginx.service      # did it crash?

For a one-line per-service summary across the whole box, I usually pair these with journalctl -u <service> -n 50 to follow the recent logs.