Alex Magazine 

$10 – $15 / Week

4 systemd tools that make everyday Linux troubleshooting much easier

Some people love systemd and can’t stop raving about it; others love to hate it and can’t stop throwing shade at it. Even though systemd remains divisive, one thing’s for sure: since nearly all modern Linux distributions have adopted it as their default init system, learning to use it can pay off big time. Here’s a basic overview of how to use four systemd tools that make troubleshooting on Linux a breeze.

Systemctl: The modern way to manage services

Systemctl is the gateway to service management on systemd-based Linux distributions. It can start and stop services, restart or reload them, enable or disable them, and help you learn so much more about the status of the different services on your system. Checking the status of a particular service is usually the first step in troubleshooting. You can use systemctl to show all running service units:

systemctl list-units --type=service
Using systemctl to list all active service units

The state option can tell you more about failed services:

systemctl list-units --state=failed
Using systemctl to list all failed service units

You can also list active and inactive service units:

systemctl list-unit-files --type=service
Using systemctl to list active and inactive units

Want to check the status of a specific service, such as a custom wallpaper changer? Ask systemctl for a status update. You can also check if a service will auto-start whenever you boot and reboot, and if it’s not enabled, you can easily enable it:

systemctl status wallpaper-changer
systemctl is-enabled [service name]

Starting, stopping, and restarting a service is also a breeze with systemctl. The start option is the easiest way to start a service. ​​​​If a service is not running at boot time, you can enable it, and if you don’t want a service to start at boot time, you can disable it:

sudo systemctl start [name of service]
sudo systemctl enable [service name.service]
sudo systemctl disable [service name.service]

For help, use:

systemctl --help

Journalctl: Making sense of service logs

Systemctl is a quick way to manage and troubleshoot services. But if you’re looking for more information about a service, journalctl is the tool for the job. Journalctl is easy to use; it lets you dive deeper into a service’s log, which is usually a treasure trove of information.

The primary way I use it is to filter the log file output for a specific service. For example, I can use it to show only the log file of the custom wallpaper changer I automated with a systemd timer.

journalctl -u wallpaper-changer.service
The GNOME 47 default desktop with the wallpaper selector open.

Build an “infinite desktop” on Ubuntu with Python and a systemd timer

Pull fresh Unsplash wallpapers and rotate them on GNOME automatically with a Python script plus a systemd service and timer.

You can use it to show multiple log files of specific service units, depending on the service you’re troubleshooting. For narrower results, use date and time filters to limit the log file output, which is usually a good way to determine when a service error occurred or when it started. For example, you can use the ‘since’ option to show logs using relative and exact time:

journalctl -u wallpaper-changer –since "3 hours ago"
journalctl -u wallpaper-changer "2025-02-01 15:00:00" -n 10
Using journalctl to show time-based service logs

You can also show the log file of the current and previous boot sessions:

journalctl -b
journalctl -b -1
journalctl to show current boot log files

To show a service’s log in real-time, use the f option to follow it.

journalctl -u wallpaper-changer.service -f
Using journalctl to show a live log file output

To troubleshoot services that have failed to start, use:

journalctl -xe
Using journalctl xe option

You can also limit the number of lines in a log file or show the log entries from the newest to the oldest:

​​​​​​​journalctl -u wallpaper-changer.service -r -n20

For help, use:

journalctl --help

Systemd-analyze: Discover the services slowing down your computer

Is your Linux system booting slower than a snail on a hot, dry day? If it is, systemd-analyze is the tool for you. You can use it to understand how the various services on your computer impact boot time. That means you can use it to identify services or configuration errors that may be slowing down system startup. The first way to use it is by analyzing the overall boot time:

systemd-analyze
systemd-analyze basic

  • Kernel: This is the time the system has spent initializing system drivers and hardware.
  • Userspace: This represents the time taken to initialize and start services.

If you suspect that a service is causing your system to boot slowly, but you’re not sure which service could be causing it, you can analyze services based on how much time they contribute to the boot time:

systemd-analyze blame
A screenshot of systemd-analyze blame command

The basic visualization features in systemd-analyze can print out a simple graphical timeline or chart of the services that start during and after the boot sequence.

systemd-analyze critical-chain
systemd-analyze plot > boot.svg

Systemd-analyze plot > boot.svg creates an SVG chart of all system services and saves it in your home folder. Drag and drop the SVG in your browser to view it. Services with the longest bars take the longest to load. Troubleshoot those first.

For help, use:

systemd-analyze --help

Coredumpctl: Inspect crash reports

If some services keep crashing randomly or unexpectedly, coredumpctl can help you inspect, troubleshoot, and resolve the issue. However, if you’ve never used coredumpctl, it may be unavailable on your device. Install it by updating your system and executing sudo apt install systemd-coredump. Once installed, you can use the list option to see a table of all crashed services and processes:

coredumpctl list
A screeshot of the coredumctl list command

To inspect and troubleshoot a particular crash, use its Process ID:

coredumpctl info 9381
A screenshot showing how to use coredumpctl to inspect a program usings its PID

If you’re troubleshooting a particular program or service, filter for that specific program/service:

coredumpctl list [program name/PID]
Using coredump to filter core dump by name

For help, use:

​​​​​​​coredumpctl –help

Systemd has many other tools and features. It can also do so much more. Ultimately, experimenting with these four systemd tools is a small step towards becoming a pro at troubleshooting Linux programs and services.

Share this post:

Leave a Reply

Your email address will not be published. Required fields are marked *

From the latest gadgets to expert reviews and unbeatable deals — dive into our handpicked content across all things tech.