Systemd

An introduction into systemd

SystemdExternal link is a system and service manager for systems running Linux. Many popular Linux distributions implemented systemd to replace the existing SysV init system, modernizing how services are started and monitored. Benefits of systemd include providing a faster boot process, a more structured approach to service management, and introduces new features.

The additional features that systemd increase the stability of the system and make services more secure. This is done by making use of some components that are part of the Linux kernel, such as cgroups, namespaces, and sandboxing functionality.

Systemd also implemented a new approach to logging. It uses a journal, a binary log that is focused on efficiency and making it available to all services. It replaces most of the standard syslog functionality that is normally responsible for storing events.

Systemd was created by Lennart Poettering and Kay Sievers with its first release (version 1) in 2010. The first Linux distribution to adopt systemd was Fedora Linux 2011, followed by OpenSUSE (2011), Arch Linux (2012), Mageia (2013), RHEL and derivatives (2014), then Debian and Ubuntu (2015.

Learn more: What is systemd?

Systemd units

To monitor and manage services on a system using systemd, unit files are used. These text-based files define what to run or do, relevant conditions, and any applicable dependencies.

Learn more:

What are the available systemd commands?

Systemd has a wide range of commands to interact with the individual systemd components. As the list is long, have a look at the overview of systemd commands to see them all, their purpose, and when they were introduced.

Relevant cheat sheets:

Using systemd for security

The unit settings of systemd allow to leverage sandboxing functionality and restricted resources. They can be used to harden systemd services, reducing the related risks of possible vulnerabilities or misuse.

Hardening profiles for systemd

To guide in securing systemd services, consider implementing the systemd hardening profiles for your services.

Predefined hardening profiles for common services running on Linux to further secure them
SoftwareDescriptionServiceVersion
ApacheWeb serverapache20.2
DovecotIMAP and POP3 serverdovecot0.2alpha
nginxWeb servernginx0.4
OpenSMTPDSMTP daemon originally created by developers for OpenBSD and ported to Linux and othersopensmtpd0.1

Articles for systemd

Auditing systemd: solving failed units with systemctl

Sometimes systemd units like services and timers may fail. Learn how to troubleshoot such issues and resolve them much easier.

Hardening profiles for systemd

Collection of predefined hardening profiles for systemd that can be used to secure your applications. With detailed explanation of the unit settings.

How to harden a systemd service unit

Harden systemd services with this step-by-step guide to gather the right information to define sandboxing features and secure and protect resources from misuse.

Run0: introduction and usage

Learn how to use the run0 command part of systemd, its purpose, and how to use it for elevating privileges to run privileged tasks.

Systemd commands

Running a Linux system with systemd? All relevant systemd commands in one overview, their purpose, and when they were first introduced.

Systemd features to secure units and services

Systemd has a wide set of unit settings available that can be used to secure units and system services. Learn which ones and how to implement them.

Systemd settings

Systemd can be configured and fine-tuned beyond imagination. This section covers what and where you can configure them, such as the many unit settings.

Systemd syscall filtering

Learn more about the system calls (syscalls) that systemd may use in commands and unit files, such as with SystemCallFilter property.

Systemd timers

Systemd timers are the unit type for scheduled tasks on Linux similar to cron. Learn how to configure them and how they differ from cron.

Systemd units and their purpose

Which systemd unit types are available and what is their goal? In this article we cover them and show some useful commands related to these units.

Troubleshooting a failed systemd unit (with examples)

Systemd units may be shown in a failed state if something goes wrong. Learn how to troubleshoot these failed units, possible causes, and how to resolve them.

Frequently Asked Questions

How to list all services with systemctl?

Run systemctl with the 'list-unit-files' subcommand and provide a filter to list all services.

systemctl list-unit-files --type=service

» Full answer and more examples


How to see the systemd version?

Run systemctl with the '--version' option.

systemctl --version

» Full answer and more examples


How to reload or restart a systemd service?

Use the systemctl command with the 'reload' or 'restart' subcommand, followed by the service.

» Full answer and more examples


How to check if a systemd service is enabled?

Use the systemctl command with the 'is-enabled' subcommand, followed by the service.

» Full answer and more examples


How to set environment variables in a systemd unit?

Define Environment or EnvironmentFile in the systemd unit to set the environment variable directly or have it retrieved from a file.

» Full answer and more examples


How to verify a systemd unit for errors?

Run the systemd-analyze command with the 'verify' subcommand, followed by the unit file.

systemd-analyze verify UNIT

» Full answer and more examples


Why does systemctl list-units show units as 'not-found'?

Units may be shown as 'not-found' if they are listed as a target in another unit file, but are not available or unknown to systemd.

» Full answer and more examples


How to see active systemd timers?

Run systemctl with the 'list-timers' subcommand.

systemctl list-timers

» Full answer and more examples


How to clear systemd journal logs by time?

Run the journalctl command and define a vacuum time to clear out the journal logs.

journalctl --vacuum-time=TIME

» Full answer and more examples


How to schedule a periodic task with systemd?

To create a repeating task, create a timer unit and link that to an existing service unit.

» Full answer and more examples


How to check if systemd is being used or active?

Use the ps command to see if systemd is used as process ID (PID) 1.

ps -p 1 -o comm=

» Full answer and more examples


How to see all enabled services with systemctl?

Run systemctl with the 'list-unit-files' subcommand and provide a filter to only show enabled services.

systemctl list-unit-files --type=service --state=enabled

» Full answer and more examples


What does 'systemctl daemon-reload' do?

When running 'systemctl daemon-reload', the systemd manager configuration is reloaded. It does this by running the generators that are helper scripts to create non-native systemd scripts. The dependency tree that links units in the right order is recreated and unit files containing their configuration are reloaded.

» Full answer and more examples


How to check if 'systemctl daemon-reload' is needed?

Use systemctl to show the NeedDaemonReload property of the specific unit.

systemctl show --property=NeedDaemonReload --value UNIT

» Full answer and more examples


How to see which syscalls are part of a systemd syscall filter set?

Run the systemd-analyze with the syscall-filter subcommand and the relevant system call set.

systemd-analyze syscall-filter @SETNAME

» Full answer and more examples


What is the difference between systemctl disable and systemctl mask?

Using systemctl disable will no longer automatically start a service, while systemctl mask will administratively disable a service from running at all.

» Full answer and more examples


How to use systemctl edit?

Run systemctl with the 'edit' subcommand and service.

systemctl edit UNIT.service

» Full answer and more examples


How to see only running services with systemctl?

Run systemctl and define the type (--type) and state (--state) options.

systemctl --type=service --state=running --legend=false

» Full answer and more examples


How to disable the background color of run0

Use run0 with the --background option and leave the value empty.

run0 --background= COMMAND

» Full answer and more examples


How to see memory usage of a service with systemctl?

Run systemctl with the 'show' subcommand and select the MemoryCurrent property, followed by the service.

systemctl show --property=MemoryCurrent nginx.service

» Full answer and more examples


See all frequently asked questions for Systemd

References