Bookmarks
ReferenceNetworks & sysadminVerified

systemd

systemd is the init system and service manager for Linux. This reference covers units, systemctl, journalctl, timers, targets, and resource limits and sandboxing for services.

checked 1 Nov · next check 8 Nov · 45 min read

Sections
12
Reading
45 min
Current version
262.2
Written from
systemd.io

Check status of the reference

Verified 1 Nov · next check 8 Nov

The sections were compared with the release notes, the check found nothing, and all source links respond.

  1. Verified
  2. Scheduled check

What systemd is and how it works

systemd is the Linux init system and service manager: the first process (PID 1), which brings the system up at boot, starts services and supervises them until shutdown. Everything it manages is described by units: services, sockets, timers and mount points.

You work with systemd whenever you start a service, read the journal or schedule a task. Services are described not by scripts but by short unit files, and systemd itself takes care of processes, restarts and start-up order. systemd runs only on Linux.

At boot the kernel hands control to systemd, which activates default.target along with all its dependencies. Units with no ordering between them start in parallel. systemd puts the processes of each service into a separate control group (cgroup) named after the unit, so it knows every process of the service, even those that have gone into the background. The output of services is collected by systemd-journald, and the manager is controlled with systemctl.

The timer backup.timer has no processes of its own: it starts the service backup.service.

What systemd consists of

ComponentWhat it does
systemd (PID 1)Starts and stops units according to their dependencies and supervises service processes
systemctlControls the manager: starting and stopping units, enabling at boot, status, reloading
systemd-journald, journalctljournald collects the journal: service output, kernel messages and syslog; journalctl reads it
systemd-logindTracks user logins and sessions and creates slices for them under user.slice
systemd-resolvedResolves names for local programs and caches DNS answers; the DNS stub listener is on 127.0.0.53

System manager and user manager

The system manager is PID 1, and it runs as root. For each logged-in user, systemd starts a separate unprivileged instance: the user manager, systemd --user, in the service user@UID.service. It has its own units and its own default.target, and the commands are the same with the --user flag: systemctl --user status.

What to know first

  • Processes, signals, users and permissions in Linux: see the Linux reference.
  • Environment variables and quoting in commands: see the Bash reference.

Section sources

the section is written from these pages

Cheat sheet

Everyday commands: services, enabling at boot, unit files, the journal, timers and boot. The examples use the service nginx and the timer backup.timer; substitute your own names. Each command is explained in its own section.

Services

TaskCommand
Status and the latest journal linessystemctl status nginx
Startsudo systemctl start nginx
Stopsudo systemctl stop nginx
Restartsudo systemctl restart nginx
Reload the program’s configurationsudo systemctl reload nginx
Reload, or restart if reloading is not supportedsudo systemctl reload-or-restart nginx
Check whether the service is running (for scripts)systemctl is-active nginx
Failed unitssystemctl list-units --failed
Clear the failed state and the restart countersudo systemctl reset-failed nginx

Enabling at boot

TaskCommand
Enable at boot and start nowsudo systemctl enable --now nginx
Disable at boot and stop nowsudo systemctl disable --now nginx
Check whether it is enabled at bootsystemctl is-enabled nginx
All installed service filessystemctl list-unit-files '*.service'

Unit files

TaskCommand
Show the unit file and all drop-inssystemctl cat nginx
Override settings with a drop-in filesudo systemctl edit nginx
Replace the whole unit filesudo systemctl edit --full nginx
Reload unit files after editing by handsudo systemctl daemon-reload
Check a unit file for errorssystemd-analyze verify /etc/systemd/system/myapp.service
Remove your overridessudo systemctl revert nginx

Journal

TaskCommand
Follow a service’s journaljournalctl -u nginx -f
Last 50 entries of a servicejournalctl -u nginx -n 50
Journal of the current bootjournalctl -b
Errors from the previous bootjournalctl -b -1 -p err
Entries since the start of todayjournalctl --since today
Kernel messagesjournalctl -k
Search message textjournalctl -u nginx -g timeout
How much space the journal usesjournalctl --disk-usage

Timers and one-off runs

TaskCommand
All timers and their next run timesystemctl list-timers
Enable a timersudo systemctl enable --now backup.timer
Check a calendar expressionsystemd-analyze calendar "Mon..Fri 09:00"
Run a command in 30 minutessudo systemd-run --on-active=30min systemctl restart nginx
Run a command with a memory limitsudo systemd-run --scope -p MemoryMax=2G make

Boot and analysis

TaskCommand
How long boot tooksystemd-analyze time
Which units took longest to startsystemd-analyze blame
The chain that delayed bootsystemd-analyze critical-chain
Security exposure score of a servicesystemd-analyze security nginx.service
System state in one wordsystemctl is-system-running
Default boot targetsystemctl get-default
Resource usage by cgroupsystemd-cgtop

Masking units and changing targets

TaskCommand
Prevent a unit from being started at allsudo systemctl mask --now nginx
Undo the masksudo systemctl unmask nginx
Change the default boot targetsudo systemctl set-default multi-user.target
Switch to rescue modesudo systemctl isolate rescue.target
Rebootsudo systemctl reboot
Power offsudo systemctl poweroff

Section sources

the section is written from these pages

Units and unit files

A unit is an object that systemd manages: a service, socket, timer, mount point or target. A unit is usually described by a text file, and the file name is the unit name: nginx.service, backup.timer. The suffix of the name sets the unit type.

TypePurpose
.serviceA service: starts a program and supervises its processes
.socketA socket, IPC or network; starts a service on the first connection (socket activation)
.timerStarts another unit on a schedule or after an interval
.targetA group of units and a synchronisation point during boot
.mount, .automountA mount point; mounting on first access
.pathStarts a service when a file or directory changes
.sliceA node in the cgroup tree: shared resource limits for a group of units
.device, .swap, .scopeA kernel device; a swap partition or file; processes started by something other than systemd itself

Where unit files live

systemd searches for a unit file in several directories in order, and a file in a directory higher in the table overrides a file of the same name lower down. Package files live in /usr/lib/systemd/system; put your own units and overrides in /etc/systemd/system.

DirectoryWhat is there
/etc/systemd/systemUnits and drop-in files from the administrator
/run/systemd/systemRuntime units, lost on reboot
/usr/local/lib/systemd/systemUnits that the administrator installed outside of packages
/usr/lib/systemd/systemUnits from distribution packages

The user manager has its own list of directories; a user puts their own units in ~/.config/systemd/user and manages them with systemctl --user.

Anatomy of a unit file

A unit file is ini-style text: sections in square brackets and key=value lines. All types share the [Unit] and [Install] sections, and the settings of the type itself go in its own section: [Service], [Timer], [Socket].

inimyapp.service
[Unit]Description=My web applicationWants=postgresql.serviceAfter=postgresql.service [Service]ExecStart=/opt/myapp/bin/server --port 8080 [Install]WantedBy=multi-user.target
  • [Unit]: the description of the unit and its relationships with other units: Description=, Wants=, After=.
  • [Service]: what to run and how; for a timer this is [Timer], for a socket [Socket].
  • [Install]: instructions for systemctl enable; WantedBy=multi-user.target creates a link to the unit in multi-user.target.wants/. systemd does not read this section while running.

Lines that start with # or ; are comments; a long line is continued with \ at the end. Boolean values are written as yes, true, on, 1 or no, false, off, 0. Times take units: 30s, 5min, 2h; a number without a unit means seconds. systemd skips an unknown key and writes a warning to the journal.

Dependencies and ordering are different things

Wants= and Requires= say what to start along with the unit, while After= and Before= say in what order. Without After=, both units start at the same time, even if one requires the other. That is why you almost always write a pair: Wants= and After= on the same unit.

Wants= and Requires= decide what to start, and After= and Before= decide in what order.
DirectiveWhat it does
Wants=Start the named unit together with this one; its failure does not prevent start-up. The recommended option
Requires=Like Wants=, but stricter: if the named unit is explicitly stopped or restarted, so is this one; if it fails to start and After= is set, this one does not start
BindsTo=Stronger than Requires=: this unit stops even if the named one exits on its own or crashes
After=, Before=Ordering only: start after or before the named unit; on shutdown, the reverse
Conflicts=Starting one unit stops the other

How to change a unit: drop-ins

A drop-in is a .conf file in the unit_name.d/ directory that systemd reads after the main file; it lists only the keys you change. All other settings, including fixes from package updates, still come from the main file. systemctl edit creates override.conf in /etc/systemd/system/nginx.service.d/ and runs daemon-reload itself, and systemctl cat shows the result: the main file and all drop-ins.

bash
sudo systemctl edit nginxsystemctl cat nginx
ininginx.service.d/override.conf
[Service]Restart=on-failureRestartSec=5s

List-type keys such as ExecStart= must first be reset in a drop-in with an empty value and then set again: a new value does not replace the old one but is added to it.

inimyapp.service.d/port.conf
[Service]# an empty value resets ExecStart= from the main fileExecStart=ExecStart=/opt/myapp/bin/server --port 9090

If you edited a unit file by hand rather than through systemctl edit, run sudo systemctl daemon-reload: until then, systemd works with the old version, even though systemctl cat already shows the new one.

Templates: name@.service

A template is a unit file with @ before the suffix: worker@.service. You can start any number of instances from one template, such as worker@emails.service and worker@reports.service, and inside the file the instance string is available as %i.

iniworker@.service
[Unit]Description=Queue worker %i [Service]User=myappExecStart=/opt/myapp/bin/worker --queue %i [Install]WantedBy=multi-user.target
bash
sudo systemctl enable --now worker@emails.servicesudo systemctl enable --now worker@reports.servicesystemctl status 'worker@*'
SpecifierExpands to
%iThe instance name: emails for worker@emails.service
%nThe full unit name
%NThe full unit name without the type suffix
%HThe host name
%hThe home directory of the user running the manager (/root for the system manager); does not depend on User=

Section sources

the section is written from these pages

Services: .service files

A service is a .service unit that starts a program and supervises it: restarts it after a failure, stops it at shutdown and collects its output into the journal. For your own application, a short file in /etc/systemd/system and the command systemctl enable --now are enough.

A reference example: a web application

inimyapp.service
[Unit]Description=My web applicationWants=postgresql.serviceAfter=postgresql.service [Service]Type=execUser=myappWorkingDirectory=/opt/myappEnvironmentFile=/etc/myapp/envExecStart=/opt/myapp/bin/server --port 8080Restart=on-failureRestartSec=5s [Install]WantedBy=multi-user.target

Save the file as /etc/systemd/system/myapp.service, reload the units and enable the service:

bash
sudo systemctl daemon-reloadsudo systemctl enable --now myappsystemctl status myapp
  • Type=exec: the service counts as started once the program has been executed; if the file or the user does not exist, systemctl start reports an error straight away.
  • User=: the user the service runs as; root by default. The user must exist before start-up: User= does not create it.
  • WorkingDirectory=: the current directory of the process; the root / if not set.
  • EnvironmentFile=: environment variables from a file of NAME=value lines.
  • ExecStart=: the start command. It is not a shell: |, > and & do not work; for a pipeline, call a shell explicitly: ExecStart=sh -c 'dmesg | tac'.
  • Restart=on-failure and RestartSec=5s: restart 5 seconds after a failure.
  • WantedBy=multi-user.target: enable adds the service to the normal boot.

When a service counts as started: Type=

Type= determines when systemd considers start-up finished and starts the units that wait for the service through After=. For long-running services the documentation recommends exec, and notify or notify-reload if the program can report readiness.

TypeThe service is started when…When to choose it
simplethe process has been created, before the program is executedThe default when ExecStart= is set; start-up errors are not visible in systemctl start
execthe program has been executedLong-running services; the recommended option
forkingthe parent process has exitedOld daemons that go into the background; used together with PIDFile=
oneshotthe process has exitedOne-off actions; with RemainAfterExit=yes the service stays active
notifythe program has sent READY=1 through sd_notify()The program supports the notification protocol
notify-reloadas for notifyThe program also reloads its configuration on the SIGHUP signal

Restarting after failures

Restart= decides when to restart the service. For long-running services the documentation recommends on-failure. A service stopped with systemctl stop is not restarted by systemd.

ValueWhen it restarts
noNever (the default)
on-failureNon-zero exit code, a signal (other than SIGHUP, SIGINT, SIGTERM, SIGPIPE), a timeout, or a watchdog trigger
on-abnormalThe same signals, timeout and watchdog, but not a non-zero exit code
alwaysOn any exit, including a successful one

After a failure the service enters the failed state, and after RestartSec= (100 ms by default) systemd starts it again. Restarts are subject to a start rate limit: more than StartLimitBurst= starts within StartLimitIntervalSec= are not allowed, and the service then stays in failed. Both settings go in the [Unit] section. Since systemd 262, you can add a random delay, RestartRandomizedDelaySec=, to the pause so that identical services do not all restart at once.

The pause before a restart is RestartSec=; the limit is StartLimitBurst= starts within StartLimitIntervalSec=.
inimyapp.service.d/restart.conf
[Unit]StartLimitIntervalSec=10minStartLimitBurst=5 [Service]Restart=on-failureRestartSec=10s

Stopping: signals and timeouts

On systemctl stop, systemd runs ExecStop= if it is set and sends SIGTERM to all remaining processes of the service. Any that have not exited within TimeoutStopSec= get SIGKILL. The command in ExecStop= must wait until the program has stopped, not just ask it to.

SettingWhat it setsDefault
KillSignal=The first signal sent on stopSIGTERM
TimeoutStopSec=How long to wait before SIGKILLthe manager’s DefaultTimeoutStopSec=
KillMode=Who receives signals: control-group sends them to all processes in the cgroup; mixed sends SIGTERM to the main process and SIGKILL to the restcontrol-group
ExecStop=A custom stop commandnot set
ExecReload=The command for systemctl reloadnot set

The documentation does not recommend KillMode=process and KillMode=none: the processes of the service keep running after it is stopped, outside resource accounting.

Commands before and after start

The ExecStartPre= commands run one after another before ExecStart=. If one of them fails, the service does not start; the prefix - allows a command to fail. Do not start long-running processes from ExecStartPre=: systemd terminates them before the main command.

inimyapp.service.d/pre.conf
[Service]# check the configuration before startingExecStartPre=/opt/myapp/bin/server --check-config# with “-”, an error (the file is missing) does not prevent start-upExecStartPre=-/usr/bin/rm /run/myapp/old.sock

Environment variables

Environment= sets variables directly in the unit, and EnvironmentFile= reads them from a file. In ExecStart=, a variable is substituted as ${NAME}, as a single argument, or as $NAME, split on whitespace. A - prefix before the path makes the file optional, and an empty ExecStart= in a drop-in resets the command from the main file.

inimyapp.service.d/env.conf
[Service]Environment=APP_ENV=production "APP_NAME=My App"# with “-”, the file may be absentEnvironmentFile=-/etc/default/myappExecStart=ExecStart=/opt/myapp/bin/server --env ${APP_ENV}
ini/etc/myapp/env
APP_PORT=8080DATABASE_URL=postgresql://myapp@127.0.0.1/myapp
inimyapp.service.d/secret.conf
[Service]LoadCredential=db-password:/etc/myapp/db-password

Section sources

the section is written from these pages

The systemctl command

systemctl is the command for managing systemd: it starts and stops units, enables them at boot, shows their state and changes the target. Starting a unit (start) takes effect now, while enabling it (enable) makes it start on every boot; the two are independent.

Starting and stopping

bash
sudo systemctl start nginxsudo systemctl stop nginxsudo systemctl restart nginx# re-read the program’s configuration, if it supports thatsudo systemctl reload nginxsudo systemctl reload-or-restart nginx

reload asks the program to re-read its own configuration, such as nginx.conf, not the unit file; the unit file is re-read by daemon-reload. Since systemd 262, several units named in one command are placed in a single transaction, and After= between them is honoured whatever order you list them in. stop does not report an error even if ExecStop= failed: systemd terminates the processes anyway.

What systemctl status shows

bash
systemctl status myapp
textexample output
● myapp.service - My web application   Loaded: loaded (/etc/systemd/system/myapp.service; enabled; preset: enabled)   Active: active (running) since Sat 2026-10-31 09:12:44 UTC; 2h ago Main PID: 812 (server)    Tasks: 9   Memory: 48.2M      CPU: 3.204s   CGroup: /system.slice/myapp.service           └─812 /opt/myapp/bin/server --port 8080 Oct 31 09:12:44 web1 systemd[1]: Started myapp.service - My web application.
LineMeaning
Loaded:Whether the unit file was found (loaded, not-found, bad-setting, masked), its path and whether it is enabled at boot
Active:The state (active, inactive, failed, activating) and since when
Main PID:The main process of the service
Tasks:, Memory:, CPU:How many tasks, how much memory and CPU time the service’s cgroup uses
CGroup:The service’s process tree
Lines at the bottomThe last 10 journal entries; use -n 50 for more, or journalctl -u for everything

The dot at the start of the line shows the state: a green ● is active, a white circle ○ is inactive, a red cross × is failed. status shows only the current or most recent run; look in the journal for earlier runs and earlier boots.

Enabling at boot: enable and disable

bash
# enable at boot and start immediatelysudo systemctl enable --now nginxsudo systemctl disable --now nginxsystemctl is-enabled nginxsystemctl is-active nginx

enable creates symbolic links according to the [Install] section, for example /etc/systemd/system/multi-user.target.wants/nginx.service, and reloads the configuration. It does not start the service itself; add --now for that. is-active and is-enabled print the state and return exit code 0 if the answer is “yes”, so they work well in scripts.

is-enabled outputMeaning
enabledThe links from [Install] exist; the unit starts at boot
disabledThe unit has an [Install] section, but it is not enabled at boot
staticThere is no [Install] section: other units start it, and you do not need to enable it
maskedStarting is forbidden by the mask command
generatedThe unit was created by a generator at boot; you do not need to enable it

Listing units

bash
systemctl list-units --type=servicesystemctl list-units --failedsystemctl list-unit-files '*.service'systemctl is-failed nginxsudo systemctl reset-failed nginxsystemctl is-system-running

list-units shows the units loaded into memory: active ones, ones with queued jobs and failed ones; with --all it also shows inactive units. list-unit-files shows the files on disk, including templates. is-failed checks whether a unit has failed, and reset-failed clears the failed mark and resets the start counter. is-system-running answers in one word: running means everything is working, degraded means some units have failed.

mask: forbid starting

mask links the unit name to /dev/null, so the unit cannot be started, either manually or as a dependency. This is stronger than disable, which only removes the start at boot. The command is intended for units that come from packages: if a file with that name already exists in /etc/systemd/system, it fails with an error.

bash
sudo systemctl mask --now apache2sudo systemctl unmask apache2

User services: --user

With --user, systemctl talks to your own user’s manager: units live in ~/.config/systemd/user and sudo is not needed. For a user’s services to run without a login session and start at boot, enable lingering for that user: the user manager then starts at boot and does not stop after logout.

bash
systemctl --user enable --now dev-server.servicesystemctl --user status dev-server.servicesudo loginctl enable-linger alice

Rebooting, powering off and the default target

bash
sudo systemctl rebootsudo systemctl poweroffsystemctl get-defaultsudo systemctl set-default multi-user.target

reboot and poweroff queue a job and return immediately, warning logged-in users with a message. set-default changes the default.target link, the target the system boots into.

Everyday flags

FlagWhat it does
--nowWith enable, disable and mask: start or stop the unit immediately
--userWork with your own user’s manager
-t, --type=Filter by type: service, timer, socket
--state=, --failedFilter by state; --failed is the same as --state=failed
-a, --allShow inactive units as well as empty properties
-n, --lines=How many journal lines status shows (10 by default)
-l, --fullDo not truncate long lines and names
--no-pagerNo paged output, for scripts
--versionThe systemd version

Section sources

the section is written from these pages

The journal and journalctl

The journal is the store kept by systemd-journald: it collects the stdout and stderr of services, kernel messages and syslog together with metadata such as the unit, PID and priority. You read it with journalctl, filtering entries by unit, boot, time and level.

Main filters

bash
# follow a service’s journaljournalctl -u nginx -fjournalctl -u nginx -n 50# errors from the previous bootjournalctl -b -1 -p errjournalctl --since "1 hour ago"journalctl --since "2026-10-31 09:00" \  --until "2026-10-31 10:00"journalctl -u nginx -g "upstream timed out"
FlagWhat it does
-u NAMEEntries for a unit: from its processes, from systemd about it, and about its core dumps
-fShow new entries as they appear
-n 50The last 50 entries; 10 without a number
-b, -b -1The current boot; the previous one (-1), the one before that (-2)
--since, --untilA time range: "2026-10-31 09:00", yesterday, "1 hour ago"
-p errPriority err and above: crit, alert, emerg
-kOnly kernel messages from the current boot
-g PATTERNSearch the message text; a lowercase pattern is case-insensitive
-o json-pretty, -o catOutput: all fields as JSON; message text only
-r, -xNewest entries first; explanations from the message catalogue

Other users’ entries and the system journal can be read by root and by members of the systemd-journal, adm and wheel groups; users see their own entries without special privileges. Add an administrator to the systemd-journal group so that they can read the journal without sudo.

Entry fields and exact filters

A journal entry is a set of fields. journald adds the metadata fields (_PID=, _UID=, _SYSTEMD_UNIT=, _EXE=) itself, and a program cannot forge them. You pass a FIELD=value condition directly to journalctl: conditions on different fields are combined with “and”, and conditions on the same field with “or”.

bash
journalctl _SYSTEMD_UNIT=nginx.service _PID=812# all entries from a program, by its pathjournalctl /usr/sbin/sshd# which values occur in a fieldjournalctl -F _SYSTEMD_UNITjournalctl -u nginx -o json-pretty -n 1

Since systemd 262, journalctl -F combined with filters (unit, boot, time, --grep) fails with an error; previously the filters were silently ignored. To get the field values for a single service, output its entries as JSON.

Persistent storage

If the /var/log/journal directory exists, the journal is stored on disk and survives a reboot; otherwise it is kept only in memory, in /run/log/journal. You can set the mode explicitly with Storage= in journald.conf. Without an on-disk journal, journalctl -b -1 will not find earlier boots; journalctl --list-boots shows which boots the journal contains. Put your own settings in a drop-in file in /etc/systemd/journald.conf.d/ rather than editing the main file.

inijournald.conf.d/60-storage.conf
[Journal]Storage=persistentSystemMaxUse=2GMaxRetentionSec=1month
bash
# apply the settings: restarting journald is safesudo systemctl restart systemd-journaldjournalctl --disk-usage
OptionWhat it setsDefault
Storage=persistent stores on disk, volatile in memory, auto on disk if /var/log/journal exists, none stores nothingset when systemd is built
SystemMaxUse=How much disk space the journal may use10% of the file system, at most 4 GiB
SystemKeepFree=How much space to leave free15%, at most 4 GiB
MaxRetentionSec=Delete entries older than this0: never delete by age
ForwardToSyslog=Forward messages to a classic syslog daemonno

Sizes are written with the suffixes K, M and G, in powers of 1024: 2G is 2 GiB. Syslog daemons such as rsyslog usually read the journal files themselves, so Storage= matters for them; you need ForwardToSyslog=yes only if the daemon receives messages through a socket. The rsyslog files in /var/log and their rotation are covered in the Linux reference, in the “System logs” section.

Cleaning up the journal

bash
# keep no more than 1 GiB of archived filessudo journalctl --vacuum-size=1Gsudo journalctl --vacuum-time=2weeks

--vacuum-size= and --vacuum-time= delete only archived journal files and leave the active ones. For that reason --disk-usage may show more than the limit you set after cleaning. To clear the current entries too, add --rotate, which first moves the active files to the archive.

Section sources

the section is written from these pages

Timers and a comparison with cron

A timer is a .timer unit that starts another unit on a schedule or after an interval. A scheduled task is a pair of files: backup.timer sets the time, backup.service says what to do, and the task’s output goes to the journal.

When the timer fires, systemd starts the service of the same name; if it is still running from the previous time, no second instance appears. With Persistent=true, the timer stores the time of the last run on disk and, if the server was off when the timer should have fired, runs the task right after boot.

Without Persistent=true, a missed run is not made up: the task runs at the next 03:00.

The timer and service pair

inibackup.service
[Unit]Description=Nightly backup of /srv [Service]Type=oneshotUser=backupExecStart=/usr/local/bin/backup-srv
inibackup.timer
[Unit]Description=Run backup.service every night [Timer]OnCalendar=*-*-* 03:00:00Persistent=trueRandomizedDelaySec=15min [Install]WantedBy=timers.target
bash
sudo systemctl daemon-reload# enable the timer, not the servicesudo systemctl enable --now backup.timersystemctl list-timers backup.timer# run the task outside the schedulesudo systemctl start backup.servicejournalctl -u backup.service -n 20

The service does not need an [Install] section: the timer starts it. If the timer and service names differ, name the service in Unit=. systemctl list-timers shows the next and previous run times.

Schedule: OnCalendar=

The format is weekday year-month-day hours:minutes:seconds. Any component can be replaced with *, listed with commas, given as a range with .. or as a step with /; the weekday and seconds can be omitted. There are shorthands: hourly, daily, weekly, monthly. The time is local by default, but you can specify a time zone.

ExpressionWhen it fires
dailyEvery day at 00:00
*-*-* 03:00:00Every day at 03:00
Mon..Fri 09:00On weekdays at 09:00
*:0/15Every 15 minutes: at :00, :15, :30, :45
*-*-01 04:00On the first of every month at 04:00
*-*~01On the last day of every month at 00:00
Sat 05:00 Asia/TashkentOn Saturdays at 05:00 Tashkent time

Check the expression before installing it: systemd-analyze calendar shows the normalised form and the next run, and --iterations= shows several upcoming ones.

bash
systemd-analyze calendar "Mon..Fri 09:00"systemd-analyze calendar --iterations=3 "*-*~01"
textexample output
  Original form: Mon..Fri 09:00Normalized form: Mon..Fri *-*-* 09:00:00    Next elapse: Mon 2026-11-02 09:00:00 UTC       From now: 1 day 12h left

Intervals instead of a calendar

Monotonic timers count time from an event rather than by the clock: OnBootSec= from boot, OnUnitActiveSec= from the last time the service ran. Together they give “every 15 minutes, the first time 5 minutes after boot”. Persistent= has no effect on such timers.

inihealthcheck.timer
[Timer]OnBootSec=5minOnUnitActiveSec=15min [Install]WantedBy=timers.target
OptionWhat it doesDefault
Persistent=Catch up on a run missed while the server was off; only with OnCalendar=. The RandomizedDelaySec= delay applies here toofalse
RandomizedDelaySec=A random delay, so that tasks on many machines do not all start at once0
AccuracySec=The accuracy window: systemd coalesces firings to wake the CPU less often1 min
Unit=Which unit to startThe service of the same name
WakeSystem=Wake the system from suspend when the timer firesfalse

Timers or cron

Aspectsystemd timercron
Describing the taskTwo files: .timer and .serviceOne line in a crontab
Task outputTo the journal: journalctl -u backupMailed to the crontab owner (MAILTO)
Server was offPersistent=true runs the task after bootA missed run is not made up
Environment and permissionsAn ordinary service: User=, resource limits, sandboxing optionsThe command runs with /usr/bin/sh as the crontab owner
Time zoneCan be set in the expression: daily Asia/TashkentOne time zone, the cron daemon’s, for all tasks
Complex datesThe last day of the month is *-*~01The command has to check the date itself

Choose a timer for server tasks that need a journal, catch-up runs, resource limits or service protection. cron is simpler when one line is enough and cron is already installed. The crontab syntax is covered in the Linux reference, in the “The cron scheduler” section.

One-off runs: systemd-run

systemd-run creates a temporary unit: with --on-active=, a timer that runs the command once after the given time; with --on-calendar=, a timer with an expression in the OnCalendar= format. Temporary units are named run-… and appear in systemctl list-timers.

bash
# restart nginx in 30 minutessudo systemd-run --on-active=30min systemctl restart nginxsystemctl list-timers 'run-*'

Section sources

the section is written from these pages

Targets and the boot process

A target is a .target unit that groups other units and acts as a synchronisation point during boot: multi-user.target is a normal server boot, graphical.target adds a graphical login. Targets replaced the SysV init runlevels.

At boot, systemd activates default.target, usually a link to multi-user.target or graphical.target, together with all its dependencies. The order is set by common targets: first mounts and swap (local-fs.target, swap.target), then sysinit.target, basic.target, and only after that ordinary services. Within each stage, units start in parallel.

An arrow means “starts earlier”; basic.target also pulls in timers, sockets and path units.
TargetMeaning
multi-user.targetA normal boot without graphics, for servers
graphical.targetmulti-user.target plus a graphical login
rescue.targetRescue mode: file systems are mounted, only basic services run, and you get a root shell
emergency.targetThe minimum: only systemd and a shell, with no other services or mounts
network-online.targetThe network is configured; only services that need it at startup pull it in
network.targetAt boot, guarantees neither physical network devices nor addresses; matters at shutdown
default.targetA link to the target the system boots into

How a service gets into the boot

WantedBy=multi-user.target in the [Install] section is an instruction for systemctl enable: create a link to the unit in /etc/systemd/system/multi-user.target.wants/. As long as the link exists, multi-user.target pulls the service in on every boot. In WantedBy=, name multi-user.target or graphical.target, not default.target; otherwise the service would also start in special boots, such as emergency or system-update boots.

bash
ls /etc/systemd/system/multi-user.target.wants/systemctl list-dependencies multi-user.target

A service that needs the network

After=network.target does not wait for the network: at boot, this target does not guarantee that physical network devices have appeared and received addresses. A service that must connect to another host at startup needs a Wants= and After= pair on network-online.target. A server that only listens on a port does not need this, and the unnecessary wait for the network slows down boot.

inisync.service
[Unit]Wants=network-online.targetAfter=network-online.target

network-online.target works only at boot: if the network drops later, systemd does not track that.

The default target and changing mode

bash
systemctl get-defaultsudo systemctl set-default multi-user.target# switch to rescue mode nowsudo systemctl isolate rescue.target

If the system does not boot, add systemd.unit=rescue.target (short form: 1) or systemd.unit=emergency.target (emergency) to the kernel parameters in the boot loader. The SysV runlevel commands runlevel, telinit and init 3 were removed in systemd 258; instead of init 3, use systemctl isolate multi-user.target.

Section sources

the section is written from these pages

Resources and cgroups

Every service runs in its own control group (cgroup), and systemd uses the kernel to limit its resources: memory, CPU share, number of processes and share of disk I/O. Set limits in the unit or change them on the fly with systemctl set-property; usage is shown by systemctl status and systemd-cgtop.

Control groups form a tree of slices: the root -.slice contains system.slice for system services, user.slice for user sessions and machine.slice for virtual machines and containers. A slice limit applies to every unit inside it, and resources are shared between siblings at each level of the tree.

A slice’s name sets its place in the tree: user-1000.slice lives in user.slice.

Limits in a unit

inimyapp.service.d/limits.conf
[Service]MemoryHigh=768MMemoryMax=1GCPUQuota=150%TasksMax=200IOWeight=50
OptionWhat it limits
MemoryHigh=Memory threshold: above it, processes are heavily throttled and have memory reclaimed. The main way to limit memory
MemoryMax=Hard memory limit: when it is exceeded, the OOM killer runs inside the service. The last line of defence
CPUQuota=Share of CPU time relative to one core: 50% is half a core, 200% is two cores
CPUWeight=Weight for dividing CPU between siblings: 1–10000, default 100
TasksMax=How many processes and threads the service may create
IOWeight=Weight for dividing disk I/O between siblings: 1–10000, default 100
MemorySwapMax=Swap limit

Sizes take the suffixes K, M, G and T, to base 1024: 1G is 1 GiB. You can also give a percentage of physical memory: MemoryMax=25%. A weight divides a resource between units in the same slice: a unit with weight 200 gets twice as much as a sibling with weight 100.

Change a limit on the fly

bash
sudo systemctl set-property nginx MemoryMax=1G CPUWeight=200# until the next reboot onlysudo systemctl set-property --runtime nginx CPUQuota=50%systemctl status nginx

set-property applies the value immediately and saves it to disk; with --runtime it lasts only until the next reboot. Not everything can be changed on the fly, but most resource settings can. An empty value resets the setting to its default.

Limit all users

Each user’s slice is named user-UID.slice. A drop-in for the truncated name user-.slice applies to the slices of all users at once, so no single user can take all of the server’s memory. Put the file in /etc/systemd/system/user-.slice.d/ and run sudo systemctl daemon-reload.

iniuser-.slice.d/50-limits.conf
[Slice]MemoryMax=4GTasksMax=1000

Who uses what

bash
# like top, but for cgroups; -m sorts by memorysystemd-cgtop -m# a single snapshot for scriptssystemd-cgtop -1 --depth=2

systemd-cgtop refreshes every second and sorts cgroups by CPU, memory or I/O. CPU load is counted up to 100% per core: up to 800% on eight cores. If the memory or disk columns are empty, turn on accounting: MemoryAccounting=yes and IOAccounting=yes.

Limit a one-off command

systemd-run --scope runs a command in a separate cgroup with the limits you set and waits for it to finish. It suits heavy one-off jobs on a production server.

bash
sudo systemd-run --scope \  -p MemoryMax=2G \  -p CPUQuota=100% \  tar czf /srv/backup/site.tar.gz /var/www

Section sources

the section is written from these pages

Service sandboxing

Sandboxing is a set of unit options that limit what a service can do if it is compromised: they block writes to the system, access to home directories and devices, privilege escalation and unneeded system calls. Turn on as many options as the service can tolerate, and check the result with systemd-analyze security.

Don’t run a service as root

Set User= and Group=. By default, system services run as root, so compromising a service immediately gives an attacker root on the server. If a service doesn’t need a permanent user, DynamicUser=yes creates one for as long as the service runs and also turns on ProtectSystem=strict, ProtectHome=read-only, PrivateTmp= and NoNewPrivileges=yes; such a service keeps its data in StateDirectory=.

inidon’t do this: everything runs as root
[Service]ExecStart=/opt/myapp/bin/server --port 80
inimyapp.service.d/hardening.conf
[Service]User=myappGroup=myapp# port 80 without rootAmbientCapabilities=CAP_NET_BIND_SERVICECapabilityBoundingSet=CAP_NET_BIND_SERVICENoNewPrivileges=yesProtectSystem=strict# creates /var/lib/myapp and makes it writableStateDirectory=myappProtectHome=yesPrivateTmp=yesPrivateDevices=yesProtectKernelTunables=yesProtectKernelModules=yesProtectControlGroups=yesRestrictAddressFamilies=AF_UNIX AF_INET AF_INET6SystemCallFilter=@system-serviceSystemCallArchitectures=native

File system

Make the service’s file system read-only and open it for writing only where the service needs to write. A compromised service then can’t replace the system’s programs or configuration.

OptionWhat it does
ProtectSystem=strictThe whole file system is read-only except /dev, /proc and /sys; full protects only /usr, /boot, /efi and /etc
ReadWritePaths=Exceptions: directories the service may write to
StateDirectory=myappCreates /var/lib/myapp for the service’s data and makes it writable
ProtectHome=yesHides /home, /root and /run/user; read-only leaves them readable
PrivateTmp=yesGives the service its own /tmp and /var/tmp; their files are deleted when the service stops
PrivateDevices=yes/dev contains only pseudo-devices such as /dev/null and /dev/random, no disks

Privileges and the kernel

Take away the privileges the service doesn’t need. An attacker then can’t escalate them through setuid programs or change kernel settings.

OptionWhat it does
NoNewPrivileges=yesStops the service and its children from gaining new privileges through setuid, setgid and file capabilities
CapabilityBoundingSet=Keeps only the listed capabilities and drops the rest
AmbientCapabilities=CAP_NET_BIND_SERVICELets a non-root service bind ports below 1024
ProtectKernelTunables=yes/proc/sys, /sys and similar paths are read-only
ProtectKernelModules=yesForbids loading and unloading kernel modules
ProtectControlGroups=yes/sys/fs/cgroup is read-only

Network and system calls

Leave the service only the socket types and system calls it needs. This closes off rarely used network protocols and dangerous kernel interfaces.

OptionWhat it does
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6Only these socket families; almost every service needs AF_UNIX, for syslog for example
PrivateNetwork=yesA private network with only lo, for services that don’t need the network
SystemCallFilter=@system-serviceAllows the set of calls typical of services; any other call kills the process with SIGSYS
SystemCallArchitectures=nativeForbids calls from foreign ABIs (x86 on x86-64) so the filter can’t be bypassed

With SystemCallErrorNumber=EPERM, a forbidden call returns an error instead of killing the process. Pass passwords through LoadCredential= rather than Environment=: environment variables are visible to unprivileged clients over D-Bus.

Checking with systemd-analyze security

bash
# summary for all running servicessystemd-analyze securitysystemd-analyze security myapp.service

The command scores each setting and calculates an overall exposure level from 0.0 to 10.0: the higher it is, the less protection the service has. A high score doesn’t mean the service is vulnerable, only that more options could help it. Only systemd settings are taken into account, not protection inside the program itself.

Turning on options without breaking things

  1. Create a drop-in with sudo systemctl edit myapp and start with a few options, for example NoNewPrivileges=yes, PrivateTmp=yes, ProtectHome=yes and ProtectKernelTunables=yes.
  2. Add ProtectSystem=strict and list in ReadWritePaths= the directories the service writes to.
  3. Restart the service and read its journal: access denials show up as write errors.
  4. From systemd 258, look inside the running service’s environment: sudo systemd-analyze unit-shell myapp.service ls /var/lib/myapp.
  5. Compare the systemd-analyze security myapp.service score before and after.

Section sources

the section is written from these pages

Common errors and diagnostics

Start diagnosing with systemctl status: it shows the state, the exit code and the last lines of the journal. Then read the service’s full journal and check the unit file. A service’s output doesn’t appear in your terminal; by default it goes to the journal.

  1. systemctl status myapp shows the state, the reason (Result:) and the process’s exit code.
  2. journalctl -u myapp -b shows everything the service has written since boot.
  3. systemctl cat myapp shows which unit file and which drop-ins are actually in effect.
  4. systemd-analyze verify /etc/systemd/system/myapp.service finds typos in keys and missing programs and dependencies.
  5. Run the command from ExecStart= by hand as the same user: sudo -u myapp /opt/myapp/bin/server --port 8080.

Service in the failed state

Cause: the main process exited with an error, was killed by a signal or didn’t finish within the timeout. The Active: line shows the reason in brackets, for example Result: exit-code, and the Main PID: line shows the exit code: status=1/FAILURE.

bashcheck
systemctl status myappjournalctl -u myapp -b -n 50
textexample output
× myapp.service - My web application   Active: failed (Result: exit-code) since Sat 2026-10-31 10:02:11 UTC; 5s ago Main PID: 1329 (code=exited, status=1/FAILURE)
  • A code from 200 to 245 is a systemd code: the failure happened before the program started. The status shows it as a number and a name without the EXIT_ prefix, for example status=203/EXEC.
  • Other codes are usually returned by the program itself: look for the cause in the last lines of its journal.
  • Once it’s fixed, start the service again: sudo systemctl restart myapp.

The common systemd codes are in the table; for the full list with explanations, run systemd-analyze exit-status.

CodeNameWhat failed
200CHDIRChanging to the WorkingDirectory= directory
203EXECStarting the program from ExecStart=; most often the file is missing or has the wrong permissions
209STDOUTSetting up standard output with StandardOutput=
217USERFinding or switching to the User= user
226NAMESPACESetting up namespaces for sandbox options such as ReadOnlyPaths=
228SECCOMPApplying the SystemCallFilter= system call filter

Exit code 203: the program won’t start

Cause: systemd couldn’t execute the file from ExecStart=. It isn’t at that path, it lacks the execute permission, or the service’s user can’t reach it.

bashcheck
systemctl cat myappls -l /opt/myapp/bin/server
bashfix
sudo chmod 755 /opt/myapp/bin/serversudo systemctl restart myapp

Changes to the unit file didn’t take effect

Cause: the file was edited by hand, but systemd is working with the version loaded in memory. systemctl cat shows the file on disk, so it may differ from what is running.

bashcheck
systemctl cat myapp
bashfix
sudo systemctl daemon-reloadsudo systemctl restart myapp

The service starts before the network or the database

Cause: the unit has Wants= or Requires= but no After=, so the units start in parallel. Or it uses After=network.target, which doesn’t wait for the network to be configured.

bashcheck
systemctl list-dependencies --after myappsystemd-analyze critical-chain myapp.service
inimyapp.service.d/order.conf
[Unit]Wants=network-online.target postgresql.serviceAfter=network-online.target postgresql.service

The service no longer restarts: start-limit-hit

Cause: the start rate limit was hit, meaning more than StartLimitBurst= starts within StartLimitIntervalSec= (by default 5 in 10 seconds). In systemctl status this appears as Result: start-limit-hit. With the default RestartSec= pause of 100 ms, a service that crashes quickly exhausts the limit almost at once and stays in failed.

bashcheck
systemctl status myapp
bashfix
# reset failed and the start countersudo systemctl reset-failed myappsudo systemctl start myapp

To stop this happening again, fix the cause of the crashes and set a pause before restarting, for example RestartSec=5s.

The system takes a long time to boot

Cause: some service takes a long time to start or is waiting for another, often for the network. blame shows how long each unit took to start, but a slow unit may just be waiting for another one; critical-chain shows the chain of waits. Services with Type=simple don’t appear in blame.

bashcheck
systemd-analyze timesystemd-analyze blamesystemd-analyze critical-chain
textexample output
multi-user.target @12.402s└─myapp.service @4.120s +8.211s  └─network-online.target @4.118s    └─systemd-networkd-wait-online.service @1.903s +2.214s

The time after @ is when the unit became active; the time after + is how long it took to start. A large + means the unit itself starts slowly; the lines beneath it are what it waited for. If a service doesn’t need the network at startup, remove its wait for network-online.target.

Boot stops or drops into emergency mode

Cause: the device for an important mount point didn’t appear, often because of an error in /etc/fstab, or a service hung at startup. Before deciding that boot has hung, wait up to 5 minutes: systemd may time out the stuck service and carry on.

Fix: boot with systemd.unit=rescue.target on the kernel command line, and if that doesn’t work, with systemd.unit=emergency.target. In emergency mode, remount the root file system read-write before editing any files. Fix /etc/fstab, reload the configuration and continue booting.

bashin the emergency shell
journalctl -b -p errmount -o remount,rw /# after editing /etc/fstabsystemctl daemon-reloadsystemctl default

Section sources

the section is written from these pages

Versions and what’s new

This reference describes systemd 262. The latest release is 262.2, from 5 November 2026. A new version comes out roughly every three months, and fixes for earlier branches ship as point releases such as 261.5.

BranchFirst releaseLatest releaseStatus
26222 September 2026262.2 — 5 November 2026Current
261, 26019 June and 17 March 2026261.5 — 6 November 2026, 260.7 — 7 November 2026Receiving fixes
25917 December 2025259.11 — 7 November 2026Receiving fixes
25817 September 2025258.12 — 17 October 2026Receiving fixes
25710 December 2024257.13 — 13 March 2026No releases since March 2026

The project doesn’t publish support periods for branches; the tags show that branches 258 to 262 are currently receiving fixes. Distributions ship their own branch and backport fixes into it, so options newer than your distribution’s branch don’t work on it. In this reference, such places are marked “since systemd 2NN”. To see the version on your machine, run systemctl --version.

Wheresystemd branch
The systemd project262 (release 262.2)
Ubuntu 26.04 LTS259 (package 259.5)
Debian 13 (trixie)257 (package 257.13)

What changed in 262

  • Services (.service files): a Type=notify-reload service must catch or block ReloadSignal= by the time of READY=1, otherwise startup fails with a protocol error.
  • Services (.service files): the new RestartRandomizedDelaySec= setting adds a random delay on top of RestartSec=, so identical services don’t all restart at once.
  • Services (.service files): UnsetEnvironment= is applied after variables in ExecStart= are expanded, so a variable can be used in the command without reaching the process’s environment.
  • The systemctl command: several units named in one command are queued in a single transaction, and the After= ordering between them is respected whatever order they appear in on the command line.
  • Journal and journalctl: journalctl -F combined with filters (unit, boot, time, --grep) now fails with an error; previously the filters were silently ignored.
  • Services (.service files): the StartLimitIntervalSec= interval is also counted while the system is suspended.
  • Resources and cgroups: slices gain ActivatingConcurrencyMax=, the number of units in a slice that may start at the same time; the rest wait in a queue.

Deprecated and removed

  • System V scripts and rc-local.service have not been supported since 260: write a .service file for the program instead. The build options -Drc-local= and -Dsysvinit-path= were also removed in 262.
  • cgroup v1 support (the legacy and hybrid hierarchies) was removed in 258: systemd always mounts cgroup v2.
  • Runlevels were removed in 258: the runlevel, telinit and init 3 commands and the runlevel[0-6].target units. Use targets and systemctl isolate instead. Since 260, the runlevel[0-6].target units can be brought back only with the build option -Dcompat-sysv-interfaces=yes.
  • Version 263 announces the removal of the /run/boot-loader-entries/ directory for boot loader entries and of the systemd-sysupdated D-Bus API: systemd-sysupdate clients are asked to move to Varlink.

Security updates

IdentifierWhat is affectedFixed in
GHSA-xxx4-mr52-4hh5systemd-nsresourced: bypass of the BPF-LSM allow list and writes to host file systems262, 261.4, 260.6
GHSA-4c2v-mg7r-xhpwsystemd-journald: an unprivileged local user can crash it262, 261.3, 260.5, 259.9, 258.11
CVE-2026-16742, GHSA-jm29-p7hh-vjhvsystemd-homed: local privilege escalation through an unverified record signature262, 261.2, 260.4, 259.8, 258.10
CVE-2026-15060, GHSA-qwv4-3gwc-w5g8systemd-machined: an unprivileged user can kill any process262, 261.2, 260.4, 259.8, 258.10
CVE-2026-15059, GHSA-652q-wxr6-h5j6systemd-oomd: an unprivileged user can kill any process261, 260.3, 259.7, 258.9
GHSA-m8q3-73v4-wvg7udev: command execution as root through a crafted iSCSI device261, 260.2, 259.6, 258.8
GHSA-vpfq-8p5f-jcqxudev: command execution as root through a crafted device260, 259.5, 258.7, 257.13
GHSA-9mj4-rrc3-gjcxsystemd-nspawn: container escape to the host through a corrupted settings file260, 259.4, 258.6, 257.12
CVE-2026-4105, GHSA-4h6x-r8vx-3862systemd-machined in branch 259: privilege escalation to root from a graphical session260, 259.4
CVE-2026-29111, GHSA-gx6q-6f99-m764PID 1: an unprivileged user can trigger an emergency stop of the manager (assert)260, 259.2, 258.5, 257.11

How to upgrade

  1. Update your distribution’s packages: systemd is updated within its branch, together with security fixes.
  2. A new systemd branch arrives with a new distribution release; Ubuntu 26.04 LTS, for example, ships branch 259.
  3. Before moving to a new branch, read the “Feature Removals and Incompatible Changes” sections of NEWS for every version between the old and the new one.

Section sources

the section is written from these pages

End of the reference

What changed

revision history · 4 entries

Every edit is saved as a revision: a snapshot of the reference, the reason and a summary of changes. The published version changes only after the same checks as at creation.

  1. Manual edit

    reason: manual edit
  2. Manual edit

    reason: manual edit
  3. Manual edit

    reason: manual edit
  4. Reference updated

Weekly check

How the reference is checked

Once a week — and right after news of a release or a vulnerability — the reference is checked in three steps.

  1. 1. Freshness

    Sections are compared with the release notes and changelogs from the official sources and with the topic’s news.

  2. 2. Errors

    Every section is read again: wrong facts, outdated APIs and flags, broken examples.

  3. 3. Links — by an HTTP request

    Every source link must respond. A broken link is a reason to recheck the section.

No findings — only the date changes. Findings — only the affected sections are rewritten, and they appear in “What changed”. A new version replaces the published one only after passing the same checks as at creation.

Statuses

Verified
no findings
Updated
sections rewritten, edits are listed
Rechecking
while the check runs, the previous version stays open
Needs review
disputed points: the verified version is shown, editors review

Last check

18 Nov · Check · updated · no findings

Found an error in the reference?

On the topic

tracks, news and other references
The whole “systemd” topic
12 sections
Another reference · DevOps & cloud

Ansible

Verified 6 Nov
All references · 61