LoggingThe Ultimate Guide

your open-source resource for understanding, analyzing, and troubleshooting system logs

curated byloggly


Using systemctl

Systemctl is an extremely powerful Linux utility that comes with systemd. It comes with a long list of options for different functionality, the most common of which are starting, stopping, restarting, or reloading a daemon. In the following examples, we will see how we can use systemctl for some of the troubleshooting purposes.

Listing Units

To check which services are installed in the local Linux system, execute this command (we are assuming you are the root user):

This should show a list of service units installed in the server regardless of their state (enabled, disabled, or static):

Note that we have included only service units here. If you want to check other types of units, you can use appropriate options in the type parameter. This is a quick way to check if a particular application (e.g., MySQL) is available in the server.

Although checking installed services in a system is useful for administration purposes, we would be more interested in services that are actually running or currently active in memory. There are two ways to check this. The first method will show us which service units are currently loaded and active. The list-units parameter with systemctl is used in this case:

The output shows services that are currently loaded and active in memory. However, some services could start and then exit after spawning another service or doing some function. They may still be active, as shown below:

In the second method, you can further fine-tune this command to list only the running services:

The following command shows the resources a service unit will depend on or the resource units that will depend on this service in recursive manner:

Running this command against the mysqld.service shows the following output:

Failed Units

To see which units failed to load or activate, run this command:

The output may or may not show any results. But if there are units that failed to load or activate, they will be listed here. In the command output shown below, we can see the kdump crash recovery service failed to activate:

If you suspect a particular service failed, you can use the is-failed parameter with systemctl. Taking the example of kdump.service, if we execute the following command:

The output is shown as failed. The same test against the crond service shows us it did not fail:

Enabled Units

To check if a service is enabled, the command syntax is this:

So, if we want to check if syslog service is enabled, the command should be:

Depending on the state, the output may be enabled or disabled.


Another systemd tool called systemd-analyze can provide valuable information about total time taken by the boot process. Executing this command:

will show an output like this:

To see what time each service unit took to load during boot, use the systemd-analyze command with the blame option:

The output will be like this:

As you can imagine, this can be a valuable tool to consider if your server is taking a long time to boot. Using the output from this command you can start troubleshooting individual services that are taking too long to load. A good tutorial on systemctl can be found in DigitalOcean. Another quick reference is in techmint.

Written & Contributed by


This guide will help software developers and system administrators become experts at using logs to better run their systems. This is a vendor-neutral, community effort featuring examples from a variety of solutions

Meet Our Contributors Become a contributor