SYSTEMCTL(1)

๐Ÿ’… SYSTEMCTL(1) ๐Ÿ’…

okay bestie, grab a snack because this is systemctl โ€” aka the manual page for the tool that runs your entire Linux box. The full title is systemctl โ€” Control the systemd system and service manager, and yeah, it's a lot. But we're gonna get through it together, one command at a time. ๐Ÿซถ


โœจ SYNOPSIS โœจ

systemctl [OPTIONS...] COMMAND [UNIT...]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

systemctl is your main-character tool for poking at and controlling the state of the "systemd" system and service manager. That's it, that's the job. ๐Ÿ’…

If you want the whole intro to the concepts and functionality this thing manages, go read systemd(1) โ€” this page is not gonna re-explain all that, it's just the commands. iykyk. ๐Ÿ’–


๐Ÿ‘‘ COMMANDS ๐Ÿ‘‘

Here's everything systemctl understands, fr fr:

๐Ÿฆ‹ Unit Commands (Introspection and Modification) ๐Ÿฆ‹

list-units [PATTERN...]

Lists the units systemd currently has chillin' in memory. And "in memory" is doing a LOT of work here โ€” that includes units referenced either directly or through a dependency, units that applications pinned programmatically, and units that were active in the past and have failed. ๐Ÿ˜ญ

By default, only units that are active, have pending jobs, or have failed get shown. Want the rest? That's what --all is for. If you pass one or more *PATTERN*s, only units matching one of them show up. And if you specified --type= or --state=, the shown units get filtered by those too.

โš ๏ธ Heads up bestie: this command does not show unit templates. It only shows instances of unit templates. Unit templates that aren't instantiated aren't runnable, so they will never, ever show up in this output. Specifically, that means foo@.service will never be shown in this list โ€” unless it's instantiated, like as foo@bar.service. Want to list installed unit template files? Use list-unit-files (it's further down, don't worry). ๐Ÿ’€

Produces output similar to:

      UNIT                         LOAD   ACTIVE SUB     DESCRIPTION
      sys-module-fuse.device       loaded active plugged /sys/module/fuse
      -.mount                      loaded active mounted Root Mount
      boot-efi.mount               loaded active mounted /boot/efi
      systemd-journald.service     loaded active running Journal Service
      systemd-logind.service       loaded active running Login Service
    โ— user@1000.service            loaded failed failed  User Manager for UID 1000
      ...
      systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories

    LOAD   = Reflects whether the unit definition was properly loaded.
    ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
    SUB    = The low-level unit activation state, values depend on unit type.

    123 loaded units listed. Pass --all to see loaded but inactive units, too.
    To show all installed unit files use 'systemctl list-unit-files'.

The header and the last unit of a given type get underlined if your terminal supports that. And a colored dot shows up next to services that were masked, not found, or otherwise failed. Little visual drama, we love it. ๐ŸŽ€

The LOAD column shows the load state, which is one of loaded, not-found, bad-setting, error, masked. The ACTIVE column shows the general unit state, and it's one of these:

  • active โ€” Started, bound, plugged in, ..., depending on the unit type.
  • inactive โ€” Stopped, unbound, unplugged, ..., depending on the unit type.
  • failed โ€” Similar to inactive, but the unit failed in some way (process returned error code on exit, crashed, an operation timed out, or after too many restarts).
  • activating โ€” Changing from inactive to active.
  • deactivating โ€” Changing from active to inactive.
  • maintenance โ€” Unit is inactive and a maintenance operation is in progress.
  • reloading โ€” Unit is active and it is reloading its configuration.
  • refreshing โ€” Unit is active and a new mount is being activated in its namespace.

The SUB column shows the unit-type-specific detailed state of the unit, and the possible values vary by unit type. Also, important: the list of possible LOAD, ACTIVE, and SUB states is not constant โ€” new systemd releases may both add and remove values. So don't you dare hardcode them. ๐Ÿ™ˆ

systemctl --state=help

That command up there may be used to display the current set of possible values. ๐Ÿ‘‘

Oh, and โ€” this is the default command. If you just run systemctl with nothing else, this is what you get. ๐Ÿ’–


list-automounts [PATTERN...]

Lists automount units currently in memory, ordered by mount path. If you give one or more *PATTERN*s, only automount units matching one of them are shown. Produces output similar to:

    WHAT        WHERE                    MOUNTED IDLE TIMEOUT UNIT
    /dev/sdb1   /mnt/test                no      120s         mnt-test.automount
    binfmt_misc /proc/sys/fs/binfmt_misc yes     0            proc-sys-fs-binfmt_misc.automount

    2 automounts listed.

Also see --show-types, --all, and --state=.

Added in version 252. โœจ


list-paths [PATTERN...]

Lists path units currently in memory, ordered by path. If one or more *PATTERN*s are specified, only path units matching one of them are shown. Produces output similar to:

    PATH                           CONDITION         UNIT                               ACTIVATES
    /run/systemd/ask-password      DirectoryNotEmpty systemd-ask-password-plymouth.path systemd-ask-password-plymouth.service
    /run/systemd/ask-password      DirectoryNotEmpty systemd-ask-password-wall.path     systemd-ask-password-wall.service
    /var/cache/cups/org.cups.cupsd PathExists        cups.path                          cups.service

    3 paths listed.

Also see --show-types, --all, and --state=.

Added in version 254. โœจ


list-sockets [PATTERN...]

Lists socket units currently in memory, ordered by listening address. If one or more *PATTERN*s are specified, only socket units matching one of them are shown. Produces output similar to:

    LISTEN           UNIT                        ACTIVATES
    kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
    /dev/rfkill      systemd-rfkill.socket       systemd-rfkill.service
    ...

    5 sockets listed.
โš ๏ธ Note: because the addresses might contains spaces, this output is not suitable for programmatic consumption. Don't you dare parse it in a script, bestie. ๐Ÿ˜ญ

Also see --show-types, --all, and --state=.

Added in version 202. โœจ


list-timers [PATTERN...]

Lists timer units currently in memory, ordered by the time they elapse next. If one or more *PATTERN*s are specified, only units matching one of them are shown. Produces output similar to:

    NEXT                         LEFT          LAST                         PASSED     UNIT                         ACTIVATES
    -                            -             Thu 2017-02-23 13:40:29 EST  3 days ago ureadahead-stop.timer        ureadahead-stop.service
    Sun 2017-02-26 18:55:42 EST  1min 14s left Thu 2017-02-23 13:54:44 EST  3 days ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
    Sun 2017-02-26 20:37:16 EST  1h 42min left Sun 2017-02-26 11:56:36 EST  6h ago     apt-daily.timer              apt-daily.service
    Sun 2017-02-26 20:57:49 EST  2h 3min left  Sun 2017-02-26 11:56:36 EST  6h ago     snapd.refresh.timer          snapd.refresh.service

What each column is giving:

  • NEXT shows the next time the timer will run.
  • LEFT shows how long till the next time the timer runs.
  • LAST shows the last time the timer ran.
  • PASSED shows how long has passed since the timer last ran.
  • UNIT shows the name of the timer
  • ACTIVATES shows the name the service the timer activates when it runs.

Also see --all and --state=.

Added in version 209. โœจ


is-active PATTERN...

Checks whether any of the specified units are active (i.e. running). Returns an exit code 0 if at least one is active, or non-zero otherwise. Unless --quiet is specified, this will also print the current unit state to standard output. ๐Ÿซถ


is-failed [PATTERN...]

Checks whether any of the specified units is in the "failed" state. If no unit is specified, it checks whether there are any failed units or ordering cycles โ€” which corresponds to the "degraded" state returned by is-system-running. Returns an exit code 0 if at least one has failed, non-zero otherwise. Unless --quiet is specified, this will also print the current unit or system state to standard output. ๐Ÿ’…

Added in version 197. โœจ


  • status [PATTERN...|PID...] โ€” bestie this is THE one you'll type like 400 times a day ๐Ÿ’…

It shows you the runtime status of your whole system, or of one or more units, and then it tacks on the most recent log lines from the journal right after. Chef's kiss.

So here's the tea on how it picks what to show:

  • No positional args + no unit filter given via --type=, --state=, or --failed? You get the status of the whole system. Periodt.
  • Add --all on top of that and it follows the system status with the status of all units.
  • Got positional args? Each one is treated as either a unit name to show, or a glob pattern</> to show every unit whose name matches, or a PID โ€” in which case it shows the unit that contains that PID.
  • Using --type=, --state=, or --failed? Then units get filtered extra hard by the TYPE and ACTIVE state.
Heads up: this thing is built for humans. It makes pretty output, not parsable output. If you need something a script can chew on, use show instead. Like, actually.

By default it only shows 10 lines of output and ellipsizes lines so they fit your terminal window. You can change that with --lines and --full (see above, bestie, they're right up there).

Also, journalctl --unit=NAME or journalctl --user-unit=NAME use a similar filter for messages and might genuinely be more convenient for you. Just saying. ๐Ÿ‘€

Okay so important caveat time: this only displays runtime status โ€” like, info about the current invocation of the unit (if it's running) or the most recent invocation (if it's not running anymore but hasn't been released from memory). Info about earlier invocations, invocations from previous system boots, or prior invocations that already got released from memory? You gotta go get those via journalctl --unit=. ๐Ÿซถ

Also also โ€” systemd implicitly loads units as necessary, so just running status will attempt to load a file. Which means this command is not useful for figuring out whether something was already loaded or not. And units may get quickly unloaded again after the operation finishes, if there's no reason to keep them in memory. It's giving "no thoughts, head empty, bye."

Example 1. Example output from systemctl status

$ systemctl status bluetooth
โ— bluetooth.service - Bluetooth service
   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; preset: enabled)
   Active: active (running) since Wed 2017-01-04 13:54:04 EST; 1 weeks 0 days ago
     Docs: man:bluetoothd(8)
 Main PID: 930 (bluetoothd)
   Status: "Running"
    Tasks: 1
   Memory: 648.0K
      CPU: 435ms
   CGroup: /system.slice/bluetooth.service
           โ””โ”€930 /usr/lib/bluetooth/bluetoothd

Jan 12 10:46:45 example.com bluetoothd[8900]: Not enough free handles to register service
Jan 12 10:46:45 example.com bluetoothd[8900]: Current Time Service could not be registered
Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output error (5)

That little dot (โ—) uses color on supported terminals to summarize the unit state at a glance, and its shape changes with state too. The full vibe check:

  • "inactive" or "maintenance" โ†’ a white circle (โ—‹)
  • "active" โ†’ a green dot (โ—)
  • "deactivating" โ†’ a white dot
  • "failed" or "error" โ†’ a red cross (ร—)
  • "reloading" or "refreshing" โ†’ a green clockwise circle arrow (โ†ป)

The "Loaded:" line shows "loaded" if the unit has been loaded into memory. Other possible values, bestie, memorize these:

  • "error" โ€” there was a problem loading it ๐Ÿ˜ญ
  • "not-found" โ€” no unit file was found for this unit
  • "bad-setting" โ€” an essential unit file setting couldn't be parsed
  • "masked" โ€” the unit file has been masked

Along with the path to the unit file, this line also shows the enablement state. Enabled units are included in the dependency network between units, so they get started at boot or via some other form of activation. The full table of possible enablement states โ€” including what "masked" even means โ€” lives in the docs for the is-enabled command. Iykyk.

The "Active:" line shows the active state. Usually it's "active" or "inactive". "active" could mean started, bound, plugged in, etc., depending on the unit type. The unit could also be mid-transition, reporting "activating" or "deactivating". And then there's the special "failed" state โ€” entered when the service failed somehow, like a crash, exiting with an error code, or timing out. If it enters the failed state, the cause gets logged for later reference. Slay, but in a sad way. ๐Ÿ’€

  • show [PATTERN...|JOB...] โ€” the computer-parsable one, no cap

Shows properties of one or more units, jobs, or the manager itself.

  • No argument? You get the manager's properties.
  • Unit name? You get that unit's properties.
  • Job ID? You get that job's properties.

By default, empty properties are suppressed. Use --all to show those too. To pick specific properties to show, use --property=. This command is the one to use whenever computer-parsable output is required. Use status if you want formatted human-readable output instead. (See? They're besties but they serve different purposes. ๐ŸŒธ)

Many properties shown by systemctl show map directly to configuration settings of the system and service manager and its unit files. But plot twist โ€” the properties shown here are generally more low-level, normalized versions of the original config settings, and they expose runtime state on top of configuration. For example, properties shown for service units include the service's current main process identifier as "MainPID" (which is runtime state), and time settings are always exposed as properties ending in the "...USec" suffix even if matching configuration options end in "...Sec" โ€” because microseconds is the normalized time unit used internally by the system and service manager. The way they normalized everything... obsessed.

For details about many of these properties, check the documentation of the D-Bus interface backing them: org.freedesktop.systemd1(5). ๐Ÿฆ‹

  • cat PATTERN... โ€” show me the receipts ๐Ÿ“œ

Shows the backing files of one or more units. It prints the "fragment" and "drop-ins" (source files) of units. Each file is preceded by a comment that includes the file name. Cute, right?

Note: this shows the contents of the backing files on disk, which might not match the system manager's understanding of these units if any unit files were updated on disk and the daemon-reload command wasn't issued since. So like, go run daemon-reload, bestie. ๐Ÿ™ˆ

Added in version 209.

  • help PATTERN...|PID... โ€” it calls the man pages for you, iconic ๐Ÿ’–

Shows manual pages for one or more units, if available. If a PID is given, the manual pages for the unit that process belongs to are shown.

Added in version 185.

  • list-dependencies [UNIT...] โ€” the family tree moment ๐ŸŒณ

Shows units required and wanted by the specified units. It recursively lists units following the Requires=, Requisite=, Wants=, ConsistsOf=, BindsTo=, and Upholds= dependencies. If no units are specified, default.target is implied. Bestie behavior honestly.

The units shown are additionally filtered by --type= and --state= if those options are specified. Note that we won't be able to use a tree structure in this case, so --plain is implied. (The tree was too powerful, it had to go. ๐Ÿ’…)

By default, only target units are recursively expanded. When --all is passed, all other units are recursively expanded as well.

Options --reverse, --after, --before may be used to change what types of dependencies are shown.

Okay real talk: this command only lists units currently loaded into memory by the service manager. So it is not suitable for getting a comprehensive list of all reverse dependencies on a specific unit, because it will not list the dependencies declared by units that aren't currently loaded. Don't be surprised, k?

Added in version 198.

  • start PATTERN... โ€” go go go, activate it โœจ

Start (activate) one or more units specified on the command line.

When more than one unit is specified, the units are enqueued in a single job transaction. This makes sure ordering dependencies (After=/Before=) configured between the listed units are honored, regardless of the order you gave them on the command line. Same deal applies to stop, restart, and the reload/restart variants below. And if a single transaction can't be put together? Separate transactions get submitted separately instead, as a fallback. It's giving "we tried."

Careful with glob patterns here, bestie. Unit glob patterns expand to names of units currently in memory. Units that aren't active and aren't in a failed state usually aren't in memory, so they will not be matched by any pattern. And for instantiated units, systemd is often unaware of the instance name until the instance has been started. So using glob patterns with start has limited usefulness. Also, secondary alias names of units are not considered. ๐Ÿ˜ญ

Option --all may be used to also operate on inactive units which are referenced by other loaded units. Note that this is not the same as operating on "all" possible units, because โ€” as the previous paragraph said โ€” such a list is ill-defined. Nevertheless, systemctl start --all GLOB may be useful if all the units that should match the pattern are pulled in by some target which is known to be loaded. ๐Ÿซถ

  • stop PATTERN... โ€” bye bye, deactivate

Stop (deactivate) one or more units specified on the command line.

This command will fail if the unit doesn't exist or if stopping the unit is prohibited (see RefuseManualStop= in systemd.unit(5)). It will not fail if any of the commands configured to stop the unit (ExecStop=, etc.) fail, because the manager will still forcibly terminate the unit anyway. She said what she said. ๐Ÿ’…

If a unit that gets stopped can still be triggered by other units, a warning containing the names of the triggering units is shown. --no-warn can be used to suppress that warning.

  • reload PATTERN... โ€” not the same as daemon-reload, I'm begging you ๐Ÿ™

Asks all units listed on the command line to reload their configuration. But listen โ€” this reloads the service-specific configuration, NOT the unit configuration file of systemd. If you want systemd to reload the configuration file of a unit, use the daemon-reload command.

In other words: for the example case of Apache, this will reload Apache's httpd.conf in the web server, not the apache.service systemd unit file.

This command should not be confused with the daemon-reload command. Seriously. They are different. Do not text them the same. ๐Ÿ˜ค
  • restart PATTERN... โ€” the ol' razzle dazzle โœจ๐Ÿ”

Stop and then start one or more units specified on the command line. And if the units aren't running yet? They'll be started anyway. Main character energy. ๐Ÿ‘‘

Note that restarting a unit with this command does not necessarily flush out all of the unit's resources before it is started again. For example, the per-service file descriptor storage facility (see FileDescriptorStoreMax= in systemd.service(5)) will remain intact as long as the unit has a job pending, and is only cleared when the unit is fully stopped and no jobs are pending anymore. If it is intended that the file descriptor store is flushed out, too, during a restart operation an explicit systemctl stop command followed by systemctl start should be issued.


๐ŸŒธ COMMANDS (still going, bestie) ๐ŸŒธ

  • try-restart PATTERN... โ€” stops and then starts one or more units you named on the command line, but only if they're already running. If they're not running? It does absolutely nothing. No cap, it just vibes. ๐Ÿ’ค
  • enqueue-marked โ€” enqueues start/stop/restart/reload jobs for every unit that has the matching "needs-*" markers set. And if a unit is marked for reload but doesn't actually support reloading, a restart gets queued instead. You can set those properties with set-property Markers=.... โœจ

Heads up though: "needs-restart" and "needs-reload" use try-restart/try-reload semantics โ€” meaning inactive units do not get started. That's different from reload-or-restart without --marked, which does start units that aren't running yet. Markers like "needs-start" still enqueue an unconditional start job.

Unless you pass --no-block, systemctl will wait for the queued jobs to finish. โณ

Added in version 260.

  • reload-or-restart PATTERN... โ€” reloads one or more units if they support it. If they don't support it, it stops them and starts them again instead. And if the units aren't running yet, they'll just be started. The versatility?? Iconic. ๐Ÿ’…

When you use this together with --marked, it's a deprecated alias of enqueue-marked.

  • try-reload-or-restart PATTERN... โ€” reloads one or more units if they support it. If not, stop and start them instead. This one does nothing if the units are not running.

Added in version 229.

  • isolate UNIT โ€” starts the unit you named on the command line plus its dependencies, and stops all the others, unless they have IgnoreOnIsolate=yes (see systemd.unit(5)). If you give a unit name with no extension, it assumes .target. ๐ŸŽฏ
โš ๏ธ Bestie, this command is dangerous. It will immediately stop processes that are not enabled in the new target โ€” possibly including the graphical environment or the terminal you're using right now. ๐Ÿ’€

Note that this operation is only allowed on units where AllowIsolate= is enabled. See systemd.unit(5) for the details.

  • kill PATTERN... โ€” sends a UNIX process signal to one or more processes of the unit. Use --kill-whom= to pick which process gets the signal. Use --signal= to pick which signal to send. And combine it with --kill-value= to enqueue a POSIX Realtime Signal with an associated value. ๐Ÿ”ชโœจ
  • clean PATTERN... โ€” removes the configuration, state, cache, logs, runtime or file descriptor store data of the units you specify. Use --what= to choose which kind of resource gets removed. For service units this can remove the directories configured with ConfigurationDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory= and RuntimeDirectory= โ€” see systemd.exec(5) for the deets. It can also clear the file descriptor store, which is enabled via FileDescriptorStoreMax=, see systemd.service(5). For timer units, this can clear out the persistent timestamp data if Persistent= is used and --what=state is selected, see systemd.timer(5). This command only applies to units that use one of these settings. If --what= isn't specified, the cache and runtime data plus the file descriptor store get removed โ€” because those three types of resources are generally redundant and reproducible the next time the unit runs. Multiple values can be separated by commas. And note: the units you name must be stopped to invoke this operation. ๐Ÿงน

Table 2. Possible values for --what=

  • "runtime" โ€” RuntimeDirectory=
  • "state" โ€” StateDirectory=
  • "cache" โ€” CacheDirectory=
  • "logs" โ€” LogsDirectory=
  • "configuration" โ€” ConfigurationDirectory=
  • "fdstore" โ€” FileDescriptorStorePreserve=
  • "all" โ€” All of the above
  • "help" โ€” Show the supported values and exit

Added in version 243.

  • freeze PATTERN... โ€” freezes one or more units you named on the command line, using the cgroup freezer. ๐ŸงŠ

Freezing the unit causes all processes inside the cgroup corresponding to that unit to be suspended. "Suspended" means the unit's processes will not be scheduled to run on the CPU until they're thawed. Note that this command is only supported on systems that use the unified cgroup hierarchy. And the unit gets automatically thawed just before a job is executed against it โ€” like, right before it's stopped.

Added in version 246.

  • thaw PATTERN... โ€” thaws (unfreezes) one or more units you named on the command line. โ˜€๏ธ

This is the inverse operation of the freeze command, and it resumes execution of the processes in the unit's cgroup.

Added in version 246.

  • set-property UNIT PROPERTY=VALUE... โ€” sets the unit properties you specify at runtime, where that's supported. This lets you change configuration parameter properties such as resource control settings on the fly. Not every property can be changed at runtime, but lots of resource control settings can โ€” mainly the ones in systemd.resource-control(5). The changes are applied immediately and stored on disk for future boots, unless you pass --runtime, in which case the settings only apply until the next reboot. The syntax of the property assignment closely follows the syntax of assignments in unit files. ๐Ÿ“

Example: systemctl set-property foobar.service CPUWeight=200

If the unit you named appears to be inactive, the changes are only stored on disk as described above, so they'll kick in when the unit is started.

Note that this command lets you change multiple properties at the same time, which is preferable to setting them one by one.

Example:

systemctl set-property foobar.service CPUWeight=200 MemoryMax=2G IPAccounting=yes

Like with unit file configuration settings, assigning an empty setting usually resets a property back to its defaults.

Example: systemctl set-property avahi-daemon.service IPAddressDeny=

Added in version 206.

  • bind UNIT PATH [PATH] โ€” bind-mounts a file or directory from the host into the specified unit's mount namespace. The first path argument is the source file or directory on the host, and the second path argument is the destination file or directory in the unit's mount namespace. When you omit the second one, the destination path in the unit's mount namespace is the same as the source path on the host. Combined with the --read-only switch, it creates a read-only bind mount. Combined with the --mkdir switch, the destination path is created first, before the mount is applied. ๐Ÿช„

Note that this option is currently only supported for units that run inside a mount namespace (e.g. with RootImage=, PrivateMounts=, etc.). This command supports bind-mounting directories, regular files, device nodes, AF_UNIX socket nodes, and FIFOs. The bind mount is ephemeral โ€” it's undone as soon as the current unit process exits. And note that the namespace being referred to here, the one the bind mount gets added to, is the one where the main service process runs. Other processes (the ones executed by ExecReload=, ExecStartPre=, etc.) run in distinct namespaces.

If the kernel supports it, any prior mount on the selected target gets replaced by the new mount. If it isn't supported, any prior mount will be over-mounted, but it remains pinned and inaccessible.

Added in version 248.

  • mount-image UNIT IMAGE [PATH [PARTITION_NAME:MOUNT_OPTIONS]] โ€” mounts an image from the host into the specified unit's mount namespace. The first path argument is the source image on the host, and the second path argument is the destination directory in the unit's mount namespace (so, inside RootImage=/RootDirectory=). The following argument, if there is one, is interpreted as a colon-separated tuple of partition name and comma-separated list of mount options for that partition. The format is the same as the service MountImages= setting. Combined with the --read-only switch, it creates a read-only mount. Combined with the --mkdir switch, the destination path is created first, before the mount is applied. ๐Ÿ’ฟโœจ

okay so quick lil heads-up about the whole mount-image situation, bestie: rn this option is only supported for units that run inside a mount namespace (think RootImage=, PrivateMounts=, that whole vibe). And the namespace we're talking about here โ€” the one the image mount gets added into โ€” is the one where the main service process runs. Other processes (ExecReload=, ExecStartPre=, etc.) are out here living in distinct namespaces, doing their own thing. ๐Ÿฆ‹

If your kernel supports it, any prior mount on the target you picked gets replaced by the new mount. If the kernel isn't giving, then any prior mount just gets over-mounted โ€” still pinned, still technically there, just fully inaccessible. ๐Ÿ’€ no cap.

Example, copy these exactly, don't improvise:

systemctl mount-image foo.service /tmp/img.raw /var/lib/image root:ro,nosuid

systemctl mount-image --mkdir bar.service /tmp/img.raw /var/lib/baz/img

Added in version 248. โœจ


service-log-level SERVICE [LEVEL]

No LEVEL argument? Then it just prints the current log level as reported by service SERVICE. Cute and informational. ๐ŸŽ€

But if you do pass that optional LEVEL? Then it changes the service's current log level to LEVEL. And LEVEL should be a normal syslog log level, meaning either a value in the range 0...7, or one of the strings emerg, alert, crit, err, warning, notice, info, debug โ€” check syslog(3) for the deets. ๐Ÿ‘‘

The service has to have the appropriate BusName=destination property and implement the generic org.freedesktop.LogControl1(5) interface. (What systemctl does under the hood is use the generic D-Bus protocol to reach the org.freedesktop.LogControl1.LogLevel interface for that D-Bus name destination.) slay.

Added in version 247. ๐Ÿ’…


service-log-target SERVICE [TARGET]

Same energy, different setting. No TARGET argument? It prints the current log target as reported by service SERVICE. ๐ŸŒธ

If you do pass the optional TARGET, it changes the service's current log target to TARGET. And TARGET should be one of these strings:

  • console โ€” log output goes to the service's standard error stream
  • kmsg โ€” log output goes to the kernel log buffer
  • journal โ€” log output goes to systemd-journald.service(8) using the native journal protocol
  • syslog โ€” log output goes to the classic syslog socket /dev/log
  • null โ€” no log output whatsoever, silence, nothing, gone
  • auto โ€” an automatically determined choice, typically the same as console if the service is invoked interactively, and journal or syslog otherwise

For most services, only a small subset of log targets even makes sense. Especially: most "normal" services should only implement console, journal, and null. Anything beyond that is only appropriate for low-level services that are active in very early boot, before proper logging has been established. iykyk. โœจ

The service must have the appropriate BusName=destination property and also implement the generic org.freedesktop.LogControl1(5) interface. (systemctl will use the generic D-Bus protocol to access the org.freedesktop.LogControl1.LogLevel interface for the D-Bus name destination.)

Added in version 247. ๐Ÿซถ


reset-failed [PATTERN...]

Resets the "failed" state of the units you name โ€” or, if you pass no unit name at all, resets the state of all units. Periodt.

So here's the lore: when a unit fails somehow (process exits with a non-zero error code, terminates abnormally, times out โ€” the whole cursed trio), it automatically enters the "failed" state, and its exit code and status get recorded so an administrator can peek at them for introspection โ€” until the service is stopped/re-started, or reset with this command. ๐Ÿ™ˆ

And it's not just the "failed" state getting reset either. It also resets various other per-unit properties: the start rate limit counter of all unit types goes back to zero, and so does the restart counter of service units. So if a unit's start limit (as configured with StartLimitIntervalSec=/StartLimitBurst=) has been hit and the unit is flat-out refusing to start again, use this command to make it startable again. main character energy, honestly. ๐Ÿ”ฅ


whoami [PID...]

Returns the units that the processes referenced by the given PIDs belong to (one per line). If you specify no PID at all, it returns the unit that the systemctl command itself is invoked in. Iconic little identity check. ๐Ÿชž

Added in version 254.


๐Ÿ‘‘ Unit File Commands ๐Ÿ‘‘

list-unit-files [PATTERN...]

Lists the unit files installed on the system, together with their enablement state (as reported by is-enabled). If you pass one or more *PATTERN*s, only unit files whose name matches one of them get shown. (Heads up: patterns matching unit file system paths are not supported.)

And unlike list-units, this command will list template units in addition to explicitly instantiated units. bestie behavior. ๐Ÿ’–

Added in version 233.


enable UNIT..., enable PATH...

Enables one or more units or unit instances. What this actually does is create a set of symlinks, as encoded in the [Install] sections of the indicated unit files. Once those symlinks exist, the system manager configuration is reloaded (equivalent to daemon-reload) so the changes are taken into account immediately. โœจ

BUT. Note that this does not also start any of the units you're enabling. If that's what you want, combine this command with the --now switch, or just invoke start with the appropriate arguments later. And in the case of unit instance enablement (i.e. enabling units shaped like foo@bar.service), symlinks named the same as the instances get created in the unit configuration directory โ€” but they point to the single template unit file they're instantiated from. ๐ŸŽ€

This command expects either valid unit names (in which case various unit file directories are automatically searched for unit files with appropriate names), or absolute paths to unit files (in which case those files are read directly). If a specified unit file lives outside the usual unit file directories, an extra symlink gets created linking it into the unit configuration path, so it's still found when commands like start come asking for it. The file system where the linked unit files live must be accessible when systemd is started โ€” e.g. anything underneath /home/ or /var/ is not allowed, unless those directories are on the root file system. ๐Ÿ’€

This command prints the file system operations it executed. You can suppress that output by passing --quiet.

Also, this operation only creates the symlinks suggested in the [Install] section of the unit files. It's the recommended way to manipulate the unit configuration directory, sure, but the administrator is free to make additional changes manually โ€” placing or removing symlinks below that directory. That's especially useful for creating configurations that deviate from the suggested default installation. In that case though, the administrator must make sure to invoke daemon-reload manually as necessary, so the changes are taken into account. ๐Ÿ™

Using this operation on units without install information? You get a warning about it. --no-warn suppresses the warning.

Do not confuse enabling units with starting (activating) them the way start does. They're orthogonal, fr fr: units may be enabled without being started, and started without being enabled. Enabling just hooks the unit into various suggested places (like so it's automatically started on boot, or when a particular kind of hardware is plugged in). Starting actually spawns the daemon process (for service units), or binds the socket (for socket units), and so on.

Depending on whether --system, --user, --runtime, or --global is specified, this enables the unit for the system, for the calling user only, for only this boot of the system, or for all future logins of all users. And in that last case โ€” note that no systemd daemon configuration is reloaded. ๐ŸŒˆ

Using enable on masked units is not supported and results in an error. Don't try it. It's giving error message.

disable UNIT...

Disables one or more units. This removes all symlinks to the unit files backing the specified units from the unit configuration directory, which undoes any changes made by enable or link. And be aware: it removes all symlinks to matching unit files โ€” including manually created symlinks โ€” not just the ones actually created by enable or link. So while disable undoes the effect of enable, the two commands are otherwise not symmetric, because disable may remove more symlinks than a prior enable invocation of the same unit ever created. ๐Ÿ˜ญ messy but true.

This command expects valid unit names only. It does not accept paths to unit files.

On top of the units you specify as arguments, all units listed in the Also= setting contained in the [Install] section of any of the unit files being operated on get disabled too. Package deal. ๐ŸŽ

This command implicitly reloads the system manager configuration after completing the operation. It does not, however, implicitly stop the units being disabled. If you want that, combine this command with the --now switch, or invoke the stop command with appropriate arguments later.

This command prints information about the file system operations (symlink removals) it executed. Suppress that with --quiet.

If a unit gets disabled but its triggering units are still active, you get a warning containing the names of the triggering units. --no-warn suppresses the warning. ๐Ÿซถ

And when this command is used with --user, the units being operated on might still be enabled in global scope โ€” meaning they can still get started automatically even after a successful disablement in user scope. In that case a warning about it is shown, which you can suppress with --no-warn. Sneaky.

This command honors --system, --user, --runtime, --global and --no-warn in a similar way as enable.

Added in version 238. ๐Ÿ’…


reenable UNIT...

Reenables one or more units, as specified on the command line. It's basically disable and enable holding hands โ€” useful for resetting the symlinks a unit file is enabled with back to the defaults configured in its [Install] section. This command expects a unit name only, it does not accept paths to unit files. ๐Ÿ‘‘

This command implicitly reloads the system manager configuration after completing the operation. Note that it does not implicitly restart the units that are being disabled. If that's what you want, either combine this command with the --now switch, or invoke the try-restart command with appropriate arguments later. โœจ

Added in version 238. โœจ


preset UNIT...

Ok bestie, preset is the glow-up reset button ๐Ÿ’… โ€” it takes one or more unit files named right there on the command line and resets their enable/disable status back to the defaults configured in the preset policy files. It literally does the same thing as disable or enable, depending on how the unit is listed in the preset files. No cap.

  • Use --preset-mode= to control whether units shall be enabled and disabled, or only enabled, or only disabled.
  • If a unit carries no install information, it just gets silently ignored by this command. ๐Ÿซฅ And UNIT must be the real unit name โ€” any alias names are ignored silently too.
  • Want the full lore on the preset policy format? That's systemd.preset(5), babes. ๐Ÿ“–

Added in version 238.

preset-all

Resets all installed unit files to the defaults configured in the preset policy file (see above, same energy โœจ).

  • Again, --preset-mode= is your girl for controlling whether units shall be enabled and disabled, or only enabled, or only disabled.

Added in version 215.

is-enabled UNIT...

This one checks whether any of the specified unit files are enabled (as with enable). It returns an exit code of 0 if at least one is enabled, and non-zero otherwise. It prints the current enable status (see the table below, it's iconic). To suppress that output, use --quiet. To show installation targets, use --full.

Table 3. is-enabled output ๐ŸŽ€

  • enabled, enabled-runtime โ€” enabled via .wants/, .requires/ or Alias= symlinks (permanently in /etc/systemd/system/, or transiently in /run/systemd/system/). Exit code: 0.
  • linked, linked-runtime โ€” made available through one or more symlinks to the unit file (permanently in /etc/systemd/system/ or transiently in /run/systemd/system/), even though the unit file might reside outside of the unit file search path. Exit code: > 0.
  • alias โ€” the name is an alias (a symlink to another unit file). Exit code: 0.
  • masked, masked-runtime โ€” completely disabled, so that any start operation on it fails (permanently in /etc/systemd/system/ or transiently in /run/systemd/systemd/). Exit code: > 0.
  • static โ€” the unit file is not enabled, and has no provisions for enabling in the [Install] unit file section. Exit code: 0.
  • indirect โ€” the unit file itself is not enabled, but it has a non-empty Also= setting in the [Install] unit file section, listing other unit files that might be enabled, or it has an alias under a different name through a symlink that is not specified in Also=. For template unit files, an instance different than the one specified in DefaultInstance= is enabled. Exit code: 0.
  • disabled โ€” the unit file is not enabled, but it contains an [Install] section with installation instructions. Exit code: > 0.
  • generated โ€” the unit file was generated dynamically via a generator tool. See systemd.generator(7). Generated unit files may not be enabled, they are enabled implicitly by their generator. Exit code: 0.
  • transient โ€” the unit file has been created dynamically with the runtime API. Transient units may not be enabled. Exit code: 0.
  • bad โ€” the unit file is invalid or another error occurred. Note that is-enabled will not actually return this state, but will print an error message instead. However, the unit file listing printed by list-unit-files might show it. Exit code: > 0.
  • not-found โ€” the unit file does not exist. Exit code: 4.

Added in version 238.

mask UNIT...

Mask one or more units, as specified on the command line. This will link those unit files to /dev/null, making it impossible to start them. ๐Ÿ’€

It's giving a stronger version of disable, because it prohibits all kinds of activation of the unit โ€” including enablement and manual activation.

Use this option with care, bestie. This is the "blocked, blocked, no notes" setting.

It honors the --runtime option to only mask temporarily, until the next reboot of the system. And the --now option may be used to ensure that the units are also stopped.

This command expects valid unit names only โ€” it does not accept unit file paths. ๐Ÿšซ

okay so real talk about what mask actually does under the hood: it drops a symlink named after the unit inside /etc/systemd/system/ (if you did not pass --runtime) or inside /run/systemd/system/ (if you did pass --runtime). So if a matching unit file already lives in one of those directories? yeah, the whole operation just fails, sorry bestie. ๐Ÿ’€

Which means this is mostly your girl for masking units that the vendor shipped โ€” those live in /usr/lib/systemd/system/, not in the two directories we just talked about โ€” but it usually does not work for units you made locally, because locally-made units are typically sitting in exactly those two directories. ๐Ÿ™ˆ Same restrictions apply in --user mode, except the directories are below the user's home directory instead.

If a unit gets masked but the stuff that triggers it is still active, you'll get a warning listing the names of those triggering units. --no-warn shuts the warning up. ๐Ÿคซ

โœจ Added in version 238.

unmask UNIT...

Unmask one or more unit files, exactly as named on the command line. This undoes what mask did โ€” the reverse card, the "jk lol". ๐ŸŽ€ Heads up though: this command wants valid unit names only, it will not take unit file paths.

โœจ Added in version 238.

Link a unit file that is not in the unit file search path into the unit file search path. This one wants an absolute path to a unit file. ๐Ÿ›ค๏ธ You can undo the whole thing with disable. What this buys you: the unit file becomes available to commands like start, even though it isn't installed directly in the unit search path.

BIG caveat, don't skip this: the filesystem where the linked unit files live has to be accessible when systemd is started โ€” so anything underneath /home/ or /var/ is not allowed, unless those directories are located on the root file system.

โœจ Added in version 233.

revert UNIT...

Revert one or more unit files back to their vendor versions. Basically: "undo everything I did, I want the factory settings back." ๐ŸŒธ

Here's the receipts on what it actually removes:

  • drop-in configuration files that modify the specified units
  • any user-configured unit file that overrides a matching vendor-supplied unit file

Specifically, for a unit "foo.service" the matching directories "foo.service.d/" with all their contained files get removed, both below the persistent and runtime configuration directories (i.e. below /etc/systemd/system and /run/systemd/system). And if the unit file has a vendor-supplied version (i.e. a unit file located below /usr/), any matching persistent or runtime unit file that overrides it is removed too.

But wait: if a unit file has no vendor-supplied version โ€” meaning it's only defined below /etc/systemd/system or /run/systemd/system, but not in a unit file stored below /usr/ โ€” then it is not removed. And also, if a unit is masked, it gets unmasked. ๐Ÿฆ‹

Effectively, this command may be used to undo all changes made with systemctl edit, systemctl set-property and systemctl mask, and puts the original unit file with its settings back in effect. The glow-up reversal. ๐Ÿ’…

โœจ Added in version 230.

add-wants TARGET UNIT..., add-requires TARGET UNIT...

Adds "Wants=" or "Requires=" dependencies, respectively, to the specified TARGET for one or more units. ๐Ÿ”—

This command honors --system, --user, --runtime and --global in a way similar to enable.

โœจ Added in version 217.

edit UNIT...

Edit or replace a drop-in snippet or the main unit file, to extend or override the definition of the specified unit. This is the "I'm customizing my build" command, iykyk. ๐ŸŽจ

Depending on whether --system (the default), --user, or --global is specified, this command will operate on the system unit files, unit files for the calling user, or the unit files shared between all users.

The editor (see the "Environment" section below) is invoked on temporary files which will be written to the real location if the editor exits successfully. After the editing is finished, configuration is reloaded, equivalent to systemctl daemon-reload --system or systemctl daemon-reload --user. For edit --global, the reload is not performed and the edits will take effect only for subsequent logins (or after a reload is requested in a different way). ๐Ÿ™ƒ

  • If --full is specified, a replacement for the main unit file will be created or edited. Otherwise, a drop-in file will be created or edited.
  • If --drop-in= is specified, the given drop-in file name will be used instead of the default override.conf.
  • The unit must exist, i.e. its main unit file must be present. If --force is specified, this requirement is ignored and a new unit may be created (with --full), or a drop-in for a nonexistent unit may be created.
  • If --runtime is specified, the changes will be made temporarily in /run/ and they will be lost on the next reboot.
  • If --stdin is specified, the new contents will be read from standard input. In this mode, the old contents of the file are discarded.
  • If the temporary file is empty upon exit, the modification of the related unit is canceled.
โš ๏ธ Note that this command cannot be used to remotely edit units, and you cannot temporarily edit units which are in /etc/, since they take precedence over /run/.
โœจ Added in version 218.

get-default

Return the default target to boot into. This returns the target unit name default.target is aliased (symlinked) to. ๐ŸŽฏ

โœจ Added in version 205.

set-default TARGET

Set the default target to boot into. This sets (symlinks) the default.target alias to the given target unit.

โœจ Added in version 205.

Machine Commands ๐Ÿ–ฅ๏ธ

list-machines [PATTERN...]

List the host and all running local containers with their state. If one or more *PATTERN*s are specified, only containers matching one of them are shown.

โœจ Added in version 212.

Job Commands โš™๏ธ

list-jobs [PATTERN...]

List jobs that are in progress. If one or more *PATTERN*s are specified, only jobs for units matching one of them are shown. ๐Ÿ“‹

When combined with --after or --before the list is augmented with information on which other job each job is waiting for, and which other jobs are waiting for it, see above.

โœจ Added in version 233.

cancel [JOB...]

Cancel one or more jobs specified on the command line by their numeric job IDs. If no job ID is specified, cancel all pending jobs. ๐Ÿ›‘

โœจ Added in version 233.

Environment Commands ๐ŸŒˆ

systemd supports an environment block that is passed to processes the manager spawns. The tea on how it works:

  • The names of the variables can contain ASCII letters, digits, and the underscore character.
  • Variable names cannot be empty or start with a digit.
  • In variable values, most characters are allowed, but the whole sequence must be valid UTF-8. (Note that control characters like newline (NL), tab (TAB), or the escape character (ESC), are valid ASCII and thus valid UTF-8).
  • The total length of the environment block is limited to _SC_ARG_MAX value defined by sysconf(3).

show-environment

Dump the systemd manager environment block. This is the environment block that is passed to all processes the manager spawns. ๐Ÿ’–

The environment block will be dumped in straightforward form suitable for sourcing into most shells. If no special characters or whitespace is present in the variable values, no escaping is performed, and the assignments have the form "VARIABLE=value". If whitespace or characters which have special meaning to the shell are present, dollar-single-quote escaping is used, and assignments have the form "VARIABLE=$'value'". This syntax is known to be supported by bash(1), zsh(1), ksh(1), and busybox(1)'s ash(1), but not dash(1) or fish(1). ๐Ÿ’€

Note that this shows the effective block, i.e. the combination of environment variables configured via configuration files, environment generators and via IPC (i.e. via the set-environment described below). At the moment a unit process is forked off, this combined environment block will be further combined with per-unit environment variables, which are not visible in this command.

set-environment VARIABLE=VALUE...

Set one or more service manager environment variables, as specified on the command line. This command will fail if variable names and values do not conform to the rules listed above. ๐Ÿšง

Note that this operates on an environment block separate from the environment block configured from service manager configuration and environment generators. Whenever a process is invoked the two blocks are combined (also incorporating any per-service environment variables), and passed to it. The show-environment verb will show the combination of the blocks, see above.

โœจ Added in version 233.

unset-environment VARIABLE...

Unset one or more systemd manager environment variables. If only a variable name is specified, it will be removed regardless of its value. If a variable and a value are specified, the variable is only removed if it has the specified value. ๐Ÿงน

Note that this operates on an environment block separate from the environment block configured from service manager configuration and environment generators. Whenever a process is invoked the two blocks are combined (also incorporating any per-service environment variables), and passed to it. The show-environment verb will show the combination of the blocks, see above.

Also note: this means this command cannot be used to unset environment variables defined in the service manager configuration files or via generators.
โœจ Added in version 233.

import-environment VARIABLE...

Import all, or one or more, environment variables set on the client into the systemd manager environment block. ๐Ÿ“ฅ

  • If a list of environment variable names is passed, client-side values are then imported into the manager's environment block.
  • If any names are not valid environment variable names or have invalid values according to the rules described above, an error is raised.
  • If no arguments are passed, the entire environment block inherited by the systemctl process is imported. In this mode, any inherited invalid environment variables are quietly ignored.
๐Ÿšจ Importing of the full inherited environment block (calling this command without any arguments) is deprecated. A shell will set dozens of variables which only make sense locally and are only meant for processes which are descendants of the shell. Such variables in the global environment block are confusing to other processes. So likeโ€ฆ don't. ๐Ÿ™…โ€โ™€๏ธ
โœจ Added in version 209.

๐ŸŽ›๏ธ Manager State Commands ๐ŸŽ›๏ธ

These ones are all about poking the manager itself โ€” the big boss process โ€” not the individual little units. Very meta. Very backstage. ๐Ÿ’…

daemon-reload

Reloads the systemd manager configuration, bestie. This reruns all generators (peep systemd.generator(7) for the lore), reloads all unit files, and recreates the entire dependency tree. Whole thing, from scratch, no cap. While the daemon is being reloaded, all sockets systemd listens on behalf of user configuration will stay accessible โ€” so nothing drops, the vibes stay uninterrupted. ๐Ÿซถ

Not to be confused with the reload command, okay?? Different thing entirely. reload is for units, this is for the manager. Do not mix them up, I'm begging. ๐Ÿ˜ญ

daemon-reexec

Reexecutes the systemd manager. It serializes the manager state, reexecutes the process, then deserializes the state again. Honestly? This one is of little use except for debugging and package upgrades. Sometimes it's helpful as a heavy-weight daemon-reload โ€” like when you want the reload energy but turned all the way up to 11. ๐Ÿ”ฅ While the daemon is being reexecuted, all sockets systemd is listening on behalf of user configuration will stay accessible.

log-level [LEVEL]

If you give it no argument, it prints the current log level of the manager. If you hand it the optional LEVEL argument, it changes the current log level of the manager to LEVEL โ€” and yes, it accepts the same values as --log-level= described in systemd(1). โœจ

Added in version 244.

log-target [TARGET]

No argument โ†’ prints the current log target of the manager. Optional TARGET argument โ†’ changes the current log target of the manager to TARGET, accepting the same values as --log-target= described in systemd(1). Same energy as above, different destination. ๐ŸŽฏ

Added in version 244.

service-watchdogs [yes|no]

No argument โ†’ prints the current state of service runtime watchdogs of the manager. Give it an optional boolean argument and it globally enables or disables the service runtime watchdogs (WatchdogSec=) and emergency actions (e.g. OnFailure= or StartLimitAction=); see systemd.service(5) for the deets.

Heads up: the hardware watchdog is not affected by this setting. That one's off doing its own thing. ๐Ÿ’€

Added in version 244.


๐ŸŒˆ System Commands ๐ŸŒˆ

Big-picture, whole-machine moves. Main character energy for the entire system, fr fr.

is-system-running

Checks whether the system is operational. Returns success (exit code 0) when the system is fully up and running โ€” specifically not in startup, shutdown or maintenance mode, and with no failed services. Failure is returned otherwise (exit code non-zero). It also prints the current state as a short string to standard output (see the table below). Use --quiet to suppress that output if you're not in the mood. ๐Ÿ™ˆ

Use --wait to wait until the boot process is completed before printing the current state and returning the appropriate error status. If --wait is in use, the states initializing or starting will not be reported โ€” instead the command just blocks until a later state (such as running or degraded) is reached. Patience is a virtue, bestie. ๐Ÿงš

Table 4. is-system-running output

  • initializing โ€” Early bootup, before basic.target is reached or the maintenance state entered. Exit code: > 0.
  • starting โ€” Late bootup, before the job queue becomes idle for the first time, or one of the rescue targets are reached. Exit code: > 0.
  • running โ€” The system is fully operational. Exit code: 0. ๐Ÿ‘‘ The dream.
  • degraded โ€” The system is operational but one or more units failed. Exit code: > 0.
  • maintenance โ€” The rescue or emergency target is active. Exit code: > 0.
  • stopping โ€” The manager is shutting down. Exit code: > 0.
  • offline โ€” The manager is not running. Specifically, this is the operational state if an incompatible program is running as system manager (PID 1). Exit code: > 0. ๐Ÿ’€
  • unknown โ€” The operational state could not be determined, due to lack of resources or another error cause. Exit code: > 0.

Added in version 215.

default

Enter default mode. This is equivalent to systemctl isolate default.target. This operation is blocking by default โ€” use --no-block to request asynchronous behavior. ๐Ÿฆ‹

rescue

Enter rescue mode. This is equivalent to systemctl isolate rescue.target. This operation is blocking by default โ€” use --no-block to request asynchronous behavior.

emergency

Enter emergency mode. This is equivalent to systemctl isolate emergency.target. This operation is blocking by default โ€” use --no-block to request asynchronous behavior. ๐Ÿšจ

halt

Shut down and halt the system. This is mostly equivalent to systemctl start halt.target --job-mode=replace-irreversibly --no-block, but it also prints a wall message to all users. This command is asynchronous โ€” it will return after the halt operation is enqueued, without waiting for it to complete. ๐Ÿ“ฌ

Note that this operation will simply halt the OS kernel after shutting down, leaving the hardware powered on. Use systemctl poweroff for powering off the system (see below).

If combined with --force, shutdown of all running services is skipped, however all processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the system halt. If --force is specified twice, the operation is immediately executed without terminating any processes or unmounting any file systems. This may result in data loss. ๐Ÿšฉ Note that when --force is specified twice the halt operation is executed by systemctl itself, and the system manager is not contacted. This means the command should succeed even when the system manager has crashed. Iconic, honestly.

If combined with --when=, shutdown will be scheduled after the given timestamp. And --when=cancel will cancel the shutdown. โฐ

poweroff

Shut down and power-off the system. This is mostly equivalent to systemctl start poweroff.target --job-mode=replace-irreversibly --no-block, but also prints a wall message to all users. This command is asynchronous โ€” it will return after the power-off operation is enqueued, without waiting for it to complete.

This command honors --force and --when= in a similar way as halt. ๐Ÿซก

reboot

Shut down and reboot the system.

This command is mostly equivalent to systemctl start reboot.target --job-mode=replace-irreversibly --no-block, but also prints a wall message to all users. This command is asynchronous โ€” it will return after the reboot operation is enqueued, without waiting for it to complete.

If the switch --reboot-argument= is given, it will be passed as the optional argument to the reboot(2) system call.

Options --boot-loader-entry=, --boot-loader-menu=, and --firmware-setup can be used to select what to do after the reboot. See the descriptions of those options for details.

This command honors --force and --when= in a similar way as halt.

If a new kernel has been loaded via kexec --load, a kexec will be performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_KEXEC=1" has been set. If a new root file system has been set up on "/run/nextroot/", a soft-reboot will be performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT=1" has been set. โœจ

Added in version 246.

kexec

Shut down and reboot the system via kexec. This command will load a kexec kernel if one was not loaded yet, or fail. A kernel may be loaded earlier by a separate step โ€” this is particularly useful if a custom initrd or additional kernel command line options are desired. The --force can be used to continue without a kexec kernel, i.e. to perform a normal reboot. The final reboot step is equivalent to systemctl start kexec.target --job-mode=replace-irreversibly --no-block.

To load a kernel, an enumeration is performed following the UAPI.1 Boot Loader Specification[1], and the default boot entry is loaded. For this step to succeed, the system must be using UEFI and the boot loader entries must be configured appropriately. bootctl list may be used to list boot entries, see bootctl(1). ๐ŸŽ€

okay so โ€” this command is asynchronous, bestie ๐Ÿ’… it comes back to you the second the reboot operation gets enqueued. It is not gonna stand there waiting for the whole thing to finish. Not its job, not its problem.

This command honors --force and --when= similarly to halt.

โœจ heads up: if a new kernel has been loaded via kexec --load, a kexec will be performed when reboot is invoked โ€” unless SYSTEMCTL_SKIP_AUTO_KEXEC=1 has been set. So set that if you don't want the auto-kexec, iykyk.

soft-reboot

Shut down and reboot userspace. This is literally equivalent to:

systemctl start soft-reboot.target --job-mode=replace-irreversibly --no-block

This command is asynchronous โ€” it returns after the reboot operation is enqueued, without waiting for it to complete. ๐Ÿฆ‹

This command honors --force and --when= in a similar way as halt.

the whole vibe: this operation only reboots userspace, leaving the kernel running. See systemd-soft-reboot.service(8) for details. ๐Ÿ‘‘

If a new root file system has been set up on /run/nextroot/, a soft-reboot will be performed when reboot is invoked โ€” unless SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT=1 has been set.

Added in version 254.

exit [EXIT_CODE]

Ask the service manager to quit. โš ๏ธ only supported for user service managers (i.e. when you're rolling with the --user option) or in containers โ€” and it's equivalent to poweroff otherwise. This command is asynchronous; it will return after the exit operation is enqueued, without waiting for it to complete.

The service manager will exit with the specified exit code, if EXIT_CODE is passed. ๐ŸŽ€

Added in version 227.

switch-root [ROOT [INIT]]

Switches to a different root directory and executes a new system manager process below it. This one is intended for use in the initrd, and it will transition from the initrd's system manager process (a.k.a. the "init" process, PID 1) to the main system manager process which is loaded from the actual host root file system. ๐Ÿ’ซ

This call takes two arguments:

  • the directory that is to become the new root directory, and
  • the path to the new system manager binary below it to execute as PID 1.

If both are omitted, or the former is an empty string, it defaults to /sysroot/. If the latter is omitted or is an empty string, a systemd binary will automatically be searched for and used as service manager. If the system manager path is omitted, equal to the empty string, or identical to the path to the systemd binary, the state of the initrd's system manager process is passed to the main system manager โ€” which allows later introspection of the state of the services involved in the initrd boot phase. ๐Ÿซถ

Added in version 209.

sleep

Put the system to sleep, through suspend, hibernate, hybrid-sleep, or suspend-then-hibernate. The sleep operation to use is automatically selected by systemd-logind.service(8). By default, suspend-then-hibernate is used, and falls back to suspend and then hibernate if not supported. Refer to the SleepOperation= setting in logind.conf(5) for more details. ๐Ÿ“–

This command is asynchronous, and will return after the sleep operation is successfully enqueued. It will not wait for the sleep/resume cycle to complete. ๐Ÿ’ค

Added in version 256.

suspend

Suspend the system. This will trigger activation of the special target unit suspend.target. This command is asynchronous, and will return after the suspend operation is successfully enqueued. It will not wait for the suspend/resume cycle to complete. ๐Ÿ˜ด

If --force is specified, and systemd-logind returned error for the operation, the error will be ignored and the operation will be tried again directly through starting the target unit. ๐Ÿ”ฅ

hibernate

Hibernate the system. This will trigger activation of the special target unit hibernate.target. This command is asynchronous, and will return after the hibernation operation is successfully enqueued. It will not wait for the hibernate/thaw cycle to complete. ๐ŸงŠ

This command honors --force in the same way as suspend.

hybrid-sleep

Hibernate and suspend the system. This will trigger activation of the special target unit hybrid-sleep.target. This command is asynchronous, and will return after the hybrid sleep operation is successfully enqueued. It will not wait for the sleep/wake-up cycle to complete. โœจ

This command honors --force in the same way as suspend.

Added in version 196.

suspend-then-hibernate

Suspend the system and hibernate it when the battery is low, or when the delay specified in systemd-sleep.conf elapsed. This will trigger activation of the special target unit suspend-then-hibernate.target. This command is asynchronous, and will return after the hybrid sleep operation is successfully enqueued. It will not wait for the sleep/wake-up or hibernate/thaw cycle to complete. ๐ŸŒธ

This command honors --force in the same way as suspend.

Added in version 240.


Parameter Syntax

Unit commands listed above take either a single unit name (designated as UNIT), or multiple unit specifications (designated as PATTERN...). ๐ŸŽฏ

Case one: the unit name with or without a suffix must be given. If the suffix is not specified (the unit name is "abbreviated"), systemctl will append a suitable suffix โ€” .service by default, and a type-specific suffix in case of commands which operate only on specific unit types. So for example,

# systemctl start sshd

and

# systemctl start sshd.service

are equivalent, as are

# systemctl isolate default

and

# systemctl isolate default.target

fun fact: (absolute) paths to device nodes are automatically converted to device unit names, and other (absolute) paths to mount unit names. So

# systemctl status /dev/sda
# systemctl status /home

are equivalent to:

# systemctl status dev-sda.device
# systemctl status home.mount

Case two: shell-style globs will be matched against the primary names of all units currently in memory; literal unit names, with or without a suffix, will be treated as in the first case. Which means: literal unit names always refer to exactly one unit, but globs may match zero units โ€” and that is not considered an error. no cap. ๐Ÿ“

Glob patterns use fnmatch(3), so normal shell-style globbing rules are used, and "*", "?", "[]" may be used. See glob(7) for more details. The patterns are matched against the primary names of units currently in memory, and patterns which do not match anything are silently skipped. For example:

# systemctl stop "sshd@*.service"

will stop all sshd@.service instances. Note that alias names of units, and units that are not in memory, are not considered for glob expansion. ๐Ÿ™ˆ

For unit file commands, the specified UNIT should be the name of the unit file (possibly abbreviated, see above), or the absolute path to the unit file:

# systemctl enable foo.service

or

# systemctl link /path/to/foo.service

โœจ OPTIONS โœจ

The following options are understood: ๐Ÿ‘‘

  • -t, --type= โ€” The argument is a comma-separated list of unit types such as service and socket. When units are listed with list-units, list-dependencies, show, or status, only units of the specified types will be shown. By default, units of all types are shown. Use --type= to reset the filter.

special case alert ๐Ÿšจ: if one of the arguments is help, a list of allowed values will be printed and the program will exit.

  • --state= โ€” The argument is a comma-separated list of unit LOAD, SUB, or ACTIVE states. When listing units with list-units, list-dependencies, show or status, show only those in the specified states. Use --state=failed or --failed to show only failed units. Use --state= to reset the filter.

special case alert ๐Ÿšจ: if one of the arguments is help, a list of allowed values will be printed and the program will exit.

Added in version 206.

  • -p, --property= โ€” When showing unit/job/manager properties with the show command, limit display to properties specified in the argument. The argument should be a comma-separated list of property names, such as "MainPID". Unless specified, all known properties are shown. If specified more than once, all properties with the specified names are shown. Shell completion is implemented for property names. ๐ŸŽ€

For the manager itself, systemctl show will show all available properties, most of which are derived or closely match the options described in systemd-system.conf(5).

Properties for units vary by unit type, so showing any unit (even a non-existent one) is a way to list properties pertaining to this type. Similarly, showing any job will list properties pertaining to all jobs. Properties for units are documented in systemd.unit(5), and the pages for individual unit types systemd.service(5), systemd.socket(5), etc.

  • -P โ€” Equivalent to --value --property=, i.e. shows the value of the property without the property name or "=". Note that using -P once will also affect all properties listed with -p/--property=. ๐Ÿ’…

Added in version 246.

  • -a, --all โ€” When listing units with list-units, also show inactive units and units which are following other units. When showing unit/job/manager properties, show all properties regardless whether they are set or not.

To list all units installed in the file system, use the list-unit-files command instead. ๐Ÿ—‚๏ธ

When listing units with list-dependencies, recursively show dependencies of all dependent units (by default only dependencies of target units are shown).

When used with status, show journal messages in full, even if they include unprintable characters or are very long. By default, fields with unprintable characters are abbreviated as "blob data". (Note that the pager may escape unprintable characters again.) ๐Ÿ‘€

  • -r, --recursive โ€” When listing units, also show units of local containers. Units of local containers will be prefixed with the container name, separated by a single colon character (":"). ๐Ÿฆ‹

Added in version 212.

  • --reverse โ€” Show reverse dependencies between units with list-dependencies, i.e. follow dependencies of type WantedBy=, RequiredBy=, UpheldBy=, PartOf=, BoundBy=, instead of Wants= and similar. ๐Ÿ”„

Added in version 203.

  • --after โ€” With list-dependencies, show the units that are ordered before the specified unit. In other words, recursively list units following the After= dependency. โฎ๏ธ
  • --after (continued from before, bestie, we're still here ๐Ÿ’…) โ€” so like, any After= dependency gets automatically mirrored into a Before= dependency. Iconic. Temporal dependencies can be specified explicitly, but they also get created implicitly for units which are WantedBy= targets (peep systemd.target(5)), and as a result of other directives too (like RequiresMountsFor=). Both the explicit and the implicit ones show up with list-dependencies.

And when you pass it to the list-jobs command? For each printed job it shows which other jobs are waiting for it. You can combine it with --before to show both the jobs waiting for each job and all the jobs each job is waiting for. Bestie behaviour fr fr. ๐Ÿซถ

Added in version 203.

  • --before โ€” with list-dependencies, show the units that are ordered after the specified unit. In other words, recursively list units following the Before= dependency. (It's giving "who comes next" energy โœจ)

When passed to the list-jobs command, for each printed job show which other jobs it is waiting for. May be combined with --after to show both the jobs waiting for each job as well as all jobs each job is waiting for.

Added in version 212.

  • --with-dependencies โ€” when used with status, cat, list-units, and list-unit-files, those commands print all specified units and the dependencies of those units. So much content, no cap.

Options --reverse, --after, --before may be used to change what types of dependencies are shown.

Added in version 245.

  • -l, --full โ€” do NOT ellipsize unit names, process tree entries, journal output, or truncate unit descriptions in the output of status, list-units, list-jobs, and list-timers. Let the names be long, they're beautiful ๐Ÿ˜ญ

Also, show installation targets in the output of is-enabled.

  • --value โ€” when printing properties with show, only print the value, and skip the property name and "=". Clean. Minimal. Aesthetic. Also see option -P above.

Added in version 230.

  • --show-types โ€” when showing sockets, show the type of the socket. iykyk ๐Ÿฆ‹

Added in version 202.

  • --job-mode= โ€” when queuing a new job, this option controls how to deal with already queued jobs. It takes one of "fail", "lenient", "replace", "replace-irreversibly", "isolate", "ignore-dependencies", "ignore-requirements", "flush", "triggering", or "restart-dependencies". Defaults to "replace", except when the isolate command is used which implies the "isolate" job mode.

If "fail" is specified and a requested operation on weak dependencies conflicts with a pending job (more specifically: causes an already pending start job to be reversed into a stop job or vice versa), cause the operation to fail. It said no and meant it ๐Ÿ’€

If "lenient" is specified and a requested operation conflicts with any active/activating unit, cause the operation to fail.

If "replace" (the default) is specified, any conflicting pending job will be replaced, as necessary.

If "replace-irreversibly" is specified, operate like "replace", but also mark the new jobs as irreversible. This prevents future conflicting transactions from replacing these jobs (or even being enqueued while the irreversible jobs are still pending). Irreversible jobs can still be cancelled using the cancel command. This job mode should be used on any transaction which pulls in shutdown.target.

"isolate" is only valid for start operations and causes all other units to be stopped when the specified unit is started. This mode is always used when the isolate command is used.

"flush" will cause all queued jobs to be canceled when the new job is enqueued.

If "ignore-dependencies" is specified, then all unit dependencies are ignored for this new job and the operation is executed immediately. If passed, no required units of the unit passed will be pulled in, and no ordering dependencies will be honored. This is mostly a debugging and rescue tool for the administrator and should not be used by applications. (Admin-only rescue behaviour, don't try this at home bestie ๐Ÿ™ˆ)

"ignore-requirements" is similar to "ignore-dependencies", but only causes the requirement dependencies to be ignored, the ordering dependencies will still be honored.

"triggering" may only be used with systemctl stop. In this mode, the specified unit and any active units that trigger it are stopped. See the discussion of Triggers= in systemd.unit(5) for more information about triggering units.

"restart-dependencies" may only be used with systemctl start. In this mode, dependencies of the specified unit will receive restart propagation, as if a restart job had been enqueued for the unit.

Added in version 209.

  • -T, --show-transaction โ€” when enqueuing a unit job (for example as effect of a systemctl start invocation or similar), show brief information about all jobs enqueued, covering both the requested job and any added because of unit dependencies. Note that the output will only include jobs immediately part of the transaction requested. It is possible that service start-up program code run as effect of the enqueued jobs might request further jobs to be pulled in. This means that completion of the listed jobs might ultimately entail more jobs than the listed ones. (So it's a brief peek, not the whole saga ๐Ÿ‘€)

Added in version 242.

  • --fail โ€” shorthand for --job-mode=fail.

When used with the kill command, if no units were killed, the operation results in an error. No units hurt? That's a fail, periodt.

Added in version 227.

  • --check-inhibitors= โ€” when system shutdown or sleep state is requested, this option controls checking of inhibitor locks. It takes one of "auto", "yes", and "no". Defaults to "auto", which means logind will perform the check and respect active inhibitor locks, but systemctl will only do a client-side check for interactive invocations (i.e. from a TTY), so that a more friendly and informative error can be returned to users. "no" disables the checks both in systemctl and systemd-logind(8).

Applications can establish inhibitor locks to prevent certain important operations (such as CD burning) from being interrupted by system shutdown or sleep. Any user may take these locks and privileged users may override these locks. If any locks are taken, shutdown and sleep state requests will normally fail (unless explicitly overridden with "no"). (Not me burning a CD in 2024 ๐Ÿ’ฟ๐Ÿ˜ญ)

Option --force provides another way to override inhibitors.

Added in version 248.

  • -i โ€” shortcut for --check-inhibitors=no.

Added in version 198.

  • --dry-run โ€” just print what would be done. Currently supported by verbs halt, poweroff, reboot, kexec, suspend, hibernate, hybrid-sleep, suspend-then-hibernate, default, rescue, emergency, and exit. Manifesting without committing, we love to see it โœจ

Added in version 236.

  • -q, --quiet โ€” suppress printing of the results of various commands and also the hints about truncated log lines. This does not suppress output of commands for which the printed output is the only result (like show). Errors are always printed. Errors are the one thing that never gets quieted, bestie ๐Ÿ’…
  • -v, --verbose โ€” display unit log output while executing unit operations. Give me ALL the lore ๐Ÿ“œ

Added in version 258.

  • --no-warn โ€” do not generate the warnings shown by default in the following cases:
    • when systemctl is invoked without procfs mounted on /proc/,
    • when using enable or disable on units without install information (i.e. do not have or have an empty [Install] section),
    • when using disable combined with --user on units that are enabled in global scope,
    • when a stop-ped, disable-d, or mask-ed unit still has active triggering units,
    • when a unit file is changed and requires daemon-reload.

Added in version 253.

  • --no-block โ€” do not synchronously wait for the requested operation to finish. If this is not specified, the job will be verified, enqueued and systemctl will wait until the unit's start-up is completed. By passing this argument, it is only verified and enqueued. This option may not be combined with --wait. (Fire and forget, but make it unix ๐Ÿ”ฅ)
  • --wait โ€” when used with start or restart, synchronously wait for started units to terminate again. This option may not be combined with --no-block. Note that this will wait forever if any given unit never terminates (by itself or by getting stopped explicitly); particularly services which use "RemainAfterExit=yes". Like, literally forever. Do not pass go, do not collect $200 ๐Ÿ’€

When used with is-system-running, wait until the boot process is completed before returning.

When used with kill, wait until the signalled units terminate. Note that this will wait forever if any given unit never terminates.

Added in version 232.

  • --user โ€” talk to the service manager of the calling user, rather than the service manager of the system. Your own lil service manager, main character energy ๐Ÿ‘‘
  • --system โ€” talk to the service manager of the system. This is the implied default.
  • --failed โ€” list units in failed state. This is equivalent to --state=failed.

Added in version 233.

  • --no-wall โ€” do not send wall message before halt, power-off and reboot. No group announcement before we go down, okay? ๐Ÿคซ
  • --global โ€” when used with enable and disable, operate on the global user configuration directory, thus enabling or disabling a unit file globally for all future logins of all users. For everyone, forever, iconic.
  • --no-reload โ€” when used with enable, disable, preset, mask, or unmask, do not implicitly reload daemon configuration after executing the changes. Skipping the lil refresh, we're built different ๐Ÿงš
  • --kill-whom= โ€” okay bestie, when you're using kill, this is literally you choosing who gets the UNIX process signal ๐Ÿ’€. It's gotta be one of main, control, cgroup or all. Here's the tea on each:
    • main โ†’ only the main process
    • control โ†’ only the control process
    • cgroup โ†’ all processes in the unit's control group
    • all โ†’ all processes of the unit

So the main process of a unit is the one that defines its whole life-time, bestie. A control process is one that gets invoked by the manager to induce state changes. Like, all processes started because of the ExecStartPre=, ExecStop= or ExecReload= settings of service units? Those are control processes โœจ. Note there's only one control process per unit at a time, since only one state change happens at a time, periodt.

For services of type Type=forking, the initial process started by the manager for ExecStart= is a control process, while the process ultimately forked off by that one is then considered the main process of the unit (if it can be determined) ๐Ÿซถ. This is different for service units of other types, where the process forked off by the manager for ExecStart= is always the main process itself.

So a service unit consists of zero or one main process, zero or one control process, plus any number of additional processes part of the unit's control group. Not all unit types manage processes of these types though. Like, for mount units, control processes are defined (which are the invocations of /usr/bin/mount and /usr/bin/umount), but no main process is defined ๐Ÿ™ˆ.

If omitted, defaults to all, except if --kill-subgroup= is used, in which case defaults to cgroup.

Added in version 252.

  • --kill-value=INT โ€” if you use this with the kill command, it enqueues a signal along with the specified integer value parameter to the specified process(es) ๐Ÿ’…. This operation is only available for POSIX Realtime Signals (i.e. --signal=SIGRTMIN+... or --signal=SIGRTMAX-...), and it ensures the signals are generated via the sigqueue(3) system call, rather than kill(3). The specified value must be a 32-bit signed integer, and may be specified either in decimal, in hexadecimal (if prefixed with "0x"), octal (if prefixed with "0o") or binary (if prefixed with "0b").

If this option is used, the signal will only be enqueued on the control or main process of the unit, never on other processes belonging to the unit, i.e. --kill-whom=all will only affect main and control processes but no other processes ๐Ÿ‘‘

Added in version 254.

  • --kill-subgroup=PATH โ€” takes a control group sub-path to send signals to, for use with the kill command ๐ŸŒธ. By default the chosen signal is delivered to all processes of the unit's cgroups (as well as the main/control processes (if outside) โ€” subject to --kill-whom=). But with this option a subgroup can be selelected instead. This functionality is only available if "cgroup" or "cgroup-fail" are used with --kill-whom=, and in fact the former is the default if --kill-subgroup= is used โœจ.

The specified path may, but doesn't have to be prefixed with a slash, and its absence or presence has no effect โ€” the path is either way taken relative to the unit's main control group path.

This functionality is only available on units where control group delegation is enabled (see Delegate= in systemd.resource-control(5)).

Added in version 258.

  • -s, --signal= โ€” when used with kill, choose which signal to send to selected processes ๐ŸŽ€. Must be one of the well-known signal specifiers such as SIGTERM, SIGINT or SIGSTOP. If omitted, defaults to SIGTERM.

The special value "help" will list the known values and the program will exit immediately, and the special value "list" will list known values along with the numerical signal numbers and the program will exit immediately. so helpful fr fr ๐Ÿ’–

  • --what= โ€” picks what type of per-unit resources to remove when the clean command is invoked (see above, bestie ๐Ÿ‘€). Takes one of configuration, state, cache, logs, runtime, fdstore to select the type of resource. This option may be specified more than once, in which case all specified resource types are removed. Also accepts the special value all as a shortcut for specifying all six resource types. If this option is not specified, defaults to the combination of cache, runtime and fdstore โ€” i.e. the three kinds of resources that are generally considered to be redundant and can be reconstructed on next invocation. The empty argument can be used to reset to this default.
Note that the explicit removal of the fdstore resource type is only useful if the FileDescriptorStorePreserve= option is enabled, since the file descriptor store is otherwise cleaned automatically when the unit is stopped.

Added in version 243.

  • -f, --force โ€” the chaotic one, the icon, the legend ๐Ÿ”ฅ. Its whole vibe depends on who it's hanging out with:
    • When used with enable, overwrite any existing conflicting symlinks.
    • When used with edit, create all of the specified units which do not already exist.
    • When used with suspend, hibernate, hybrid-sleep, or suspend-then-hibernate, the error returned by systemd-logind will be ignored, and the operation will be performed directly through starting the corresponding units.
    • When used with halt, poweroff, reboot, or kexec, execute the selected operation without shutting down all units. However, all processes will be killed forcibly and all file systems are unmounted or remounted read-only. This is hence a drastic but relatively safe option to request an immediate reboot ๐Ÿซถ. If --force is specified twice for these operations (with the exception of kexec), they will be executed immediately, without terminating any processes or unmounting any file systems.
Warning โš ๏ธ โ€” Specifying --force twice with any of these operations might result in data loss. Note that when --force is specified twice the selected operation is executed by systemctl itself, and the system manager is not contacted. This means the command should succeed even when the system manager has crashed ๐Ÿ’€
  • --message= โ€” when used with halt, poweroff or reboot, set a short message explaining the reason for the operation ๐Ÿ’Œ. The message will be logged together with the default shutdown message.

Added in version 225.

  • --now โ€” when used with enable, disable, mask, or reenable, also start/stop/try-restart the units after the specified unit file operations succeed โœจ. like, do it all at once, we love efficiency.

Added in version 220.

  • --root= โ€” when used with enable/disable/is-enabled (and related commands), use the specified root path when looking for unit files ๐ŸŒˆ. If this option is present, systemctl will operate on the file system directly, instead of communicating with the systemd daemon to carry out changes.
  • --image=image โ€” takes a path to a disk image file or block device node ๐Ÿฆ‹. If specified, all operations are applied to file system in the indicated disk image. This option is similar to --root=, but operates on file systems stored in disk images or block devices. The disk image should either contain just a file system or a set of file systems within a GPT partition table, following the UAPI.2 Discoverable Partitions Specification[2]. For further information on supported disk images, see systemd-nspawn(1)'s switch of the same name.

Added in version 252.

  • --image-policy=policy โ€” takes an image policy string as argument, as per systemd.image-policy(7) ๐Ÿ‘‘. The policy is enforced when operating on the disk image specified via --image=, see above. If not specified, defaults to the "*" policy, i.e. all recognized file systems in the image are used.
  • --runtime โ€” when used with enable, disable, edit, (and related commands), make changes only temporarily, so that they are lost on the next reboot ๐Ÿ’ซ. This will have the effect that changes are not made in subdirectories of /etc/ but in /run/, with identical immediate effects, however, since the latter is lost on reboot, the changes are lost too.

Similarly, when used with set-property, make changes only temporarily, so that they are lost on the next reboot.

  • --preset-mode= โ€” takes one of "full" (the default), "enable-only", "disable-only" ๐ŸŒธ. When used with the preset or preset-all commands, controls whether units shall be disabled and enabled according to the preset rules, or only enabled, or only disabled.

Added in version 215.

  • -n, --lines= โ€” when used with status, controls the number of journal lines to show, counting from the most recent ones ๐Ÿ““. Takes a positive integer argument, or 0 to disable journal output. Defaults to 10.
  • -o, --output= โ€” when used with status, controls the formatting of the journal entries that are shown โœจ. For the available choices, see journalctl(1). Defaults to "short".
  • --firmware-setup โ€” when used with the reboot, poweroff, or halt command, indicate to the system's firmware to reboot into the firmware setup interface for the next boot ๐Ÿ–ฅ๏ธ. Note that this functionality is not available on all systems.

Added in version 220.

  • --boot-loader-menu=timeout โ€” when used with the reboot, poweroff, or halt command, indicate to the system's boot loader to show the boot loader menu on the following boot ๐ŸŽ€. Takes a time value as parameter โ€” indicating the menu timeout. Pass zero in order to disable the menu timeout. Note that not all boot loaders support this functionality.

Added in version 242.

  • --boot-loader-entry=ID โ€” when used with the reboot, poweroff, or halt command, indicate to the system's boot loader to boot into a specific boot loader entry on the following boot ๐Ÿ’…. Takes a boot loader entry identifier as argument, or "help" in order to list available entries. Note that not all boot loaders support this functionality.

Added in version 242.

  • --reboot-argument= โ€” this switch is used with reboot ๐ŸŒˆ. The value is architecture and firmware specific. As an example, "recovery" might be used to trigger system recovery, and "fota" might be used to trigger a "firmware over the air" update.

Added in version 246.

  • --kernel-cmdline= โ€” okay so when you're rolling with kexec, this one appends whatever string you give it to the kernel command line options of the kexec kernel ๐Ÿ’ซ That kernel command line comes from the boot loader entry of the kernel you're currently booted into (which is what gets picked automatically when no kexec kernel is preloaded โ€” peep kexec above for that whole situation). The string gets appended, separated from the existing options by a single space. You can hand this option over more than once, and then the strings get appended in the order you gave them. Heads up though: systemctl kexec will straight up fail if you specify this while a kexec kernel is already loaded ๐Ÿ™ˆ

The kexec kernel command line gets assembled in a fixed order, no matter what order you typed the options in on the command line: first the command line from the boot loader entry, then the command line of the currently running kernel (that's if --kernel-cmdline-reuse is in play), and finally the strings from --kernel-cmdline=. After all that, arguments that are exactly identical and show up more than once get removed, keeping the last occurrence. Ngl, only byte-for-byte identical arguments get deduplicated: like "foo=bar" and "foo=quux" both stay, because they're not identical (and the latter wins anyway, since the kernel uses the last assignment of a given parameter).

Added in version 261. โœจ

  • --kernel-cmdline-reuse โ€” basically the same energy as --kernel-cmdline=, except instead of taking a string to append as an argument, it reuses the command line of the kernel that's currently running. So useful bestie โ€” it boots the kexec kernel with the same command line options your running system was booted with, including any modifications applied at boot time. Just like with --kernel-cmdline=, the reused command line gets added onto the command line from the boot loader entry, and systemctl kexec will fail if you specify this while a kexec kernel is already loaded. You can combine this with --kernel-cmdline= โ€” scroll up to --kernel-cmdline= for the order the various sources get combined and deduplicated in. ๐Ÿ’…

Added in version 262. โœจ

  • --plain โ€” when you use this with list-dependencies, list-units or list-machines, the output prints as a list instead of a tree, and the bullet circles are omitted. No tree vibes, just a clean list. ๐ŸŒธ

Added in version 203. โœจ

  • --timestamp= โ€” changes the format of printed timestamps. Here are the values you can use, bestie:
    • pretty (this is the default) โ€” "Day YYYY-MM-DD HH:MM:SS TZ"

Added in version 248. โœจ

  • unix โ€” "@seconds-since-the-epoch"

Added in version 251. โœจ

  • us, ฮผs โ€” "Day YYYY-MM-DD HH:MM:SS.UUUUUU TZ"

Added in version 248. โœจ

  • utc โ€” "Day YYYY-MM-DD HH:MM:SS UTC"

Added in version 248. โœจ

  • us+utc, ฮผs+utc โ€” "Day YYYY-MM-DD HH:MM:SS.UUUUUU UTC"

Added in version 248. โœจ

Added in version 247. โœจ

  • --mkdir โ€” when you use this with bind, it creates the destination file or directory before applying the bind mount. And listen, even though the name makes it sound like it's only for directories, this option also creates the destination file node to mount over if the thing you're mounting isn't a directory but a regular file, device node, socket or FIFO. Versatile queen ๐Ÿ‘‘

Added in version 248. โœจ

  • --read-only โ€” when you use this with bind, it creates a read-only bind mount. ๐Ÿ”’

Added in version 248. โœจ

  • --drop-in=NAME โ€” when you use this with edit, it uses NAME as the drop-in file name instead of override.conf. ๐ŸŽ€

Added in version 253. โœจ

  • --when= โ€” when you use this with halt, poweroff, reboot or kexec, it schedules the action to happen at the given timestamp, which should follow the syntax documented in systemd.time(7) section "PARSING TIMESTAMPS". And specially: if "show" is given, the currently scheduled action gets shown, and you can cancel it by passing an empty string or "cancel". "auto" will schedule the action according to the maintenance window, or one minute in the future.

The timestamp you specify is a lower bound only โ€” it declares the earliest point in time the requested action may take place, meaning the action runs as soon as possible, but not before that timestamp. It's not a condition that gets checked, and specifying a timestamp in the past is not an error: the action just executes immediately. This is intentional, because the alternative would be racy and surprising โ€” think about --when=now, which by the time the request is processed necessarily refers to the past, or --when=+50ms, which might well have already elapsed due to scheduling latencies before the request even gets dispatched. In both cases the requested action still happens, because you asked for it, bestie. ๐Ÿ’–

If you want a timestamp in the past to not result in the action executing, you have to check for that explicitly before invoking systemctl. No cap.

Added in version 254. โœจ

  • --stdin โ€” when you use this with edit, the contents of the file get read from standard input and the editor is not launched. In this mode, the old contents of the file are completely replaced. This is so useful to "edit" unit files from scripts:
$ systemctl edit --drop-in=limits.conf --stdin some-service.service <<EOF
[Unit]
AllowedCPUs=7,11
EOF

You can "edit" multiple drop-ins in this mode too โ€” the same contents get written to all of them. ๐Ÿซถ

Added in version 256. โœจ

  • -H, --host= โ€” executes the operation remotely. Give it a hostname, or a username and hostname separated by "@", to connect to. The hostname may optionally be suffixed by a port ssh is listening on, separated by ":", and then a container name, separated by "/", which connects directly to a specific container on the specified host. This uses SSH to talk to the remote machine manager instance. Container names can be enumerated with machinectl -H HOST. And put IPv6 addresses in brackets, bestie. ๐ŸŒ
  • -M, --machine= โ€” executes the operation on a local container. Give it a container name to connect to, optionally prefixed by a user name to connect as and a separating "@" character. If the special string ".host" is used in place of the container name, a connection to the local system is made (which is useful to connect to a specific user's user bus: "--user --machine=lennart@.host"). If the "@" syntax isn't used, the connection is made as root user. If the "@" syntax is used, either the left hand side or the right hand side may be omitted (but not both) โ€” in which case the local user name and ".host" are implied. ๐Ÿ’…
  • -C, --capsule= โ€” executes the operation on a capsule. Give it a capsule name to connect to. Peep capsule@.service(5) for the details about capsules. ๐Ÿฆ‹

Added in version 256. โœจ

  • --no-ask-password โ€” does not query the user for authentication for privileged operations. No pop-up, no password prompt, just vibes. ๐Ÿ™ˆ
  • --no-pager โ€” does not pipe output into a pager. ๐Ÿ“„
  • --legend=BOOL โ€” enables or disables printing of the legend, aka the column headers and the footer with hints. The legend is printed by default, unless it's disabled with --quiet or similar. ๐Ÿ‘‘
  • -h, --help โ€” prints a short help text and exits. โœจ
  • --version โ€” prints a short version string and exits. โœจ

๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

On success, 0 is returned, and a non-zero failure code otherwise. Simple as that. ๐Ÿ’–

systemctl uses the return codes defined by LSB, as defined in LSB 3.0.0[3]. ๐Ÿ”ฅ

Table 5. LSB return codes

  • 0 โ€” Description in LSB: "program is running or service is OK" ยท Use in systemd: unit is active โœ…
  • 1 โ€” Description in LSB: "program is dead and /var/run pid file exists" ยท Use in systemd: unit not failed (used by is-failed)
  • 2 โ€” Description in LSB: "program is dead and /var/lock lock file exists" ยท Use in systemd: unused ๐Ÿ’€
  • 3 โ€” Description in LSB: "program is not running" ยท Use in systemd: unit is not active
  • 4 โ€” Description in LSB: "program or service status is unknown" ยท Use in systemd: no such unit ๐Ÿ˜ญ
Ngl, the mapping of LSB service states to systemd unit states is imperfect, so it's better to not rely on those return values but to look for specific unit states and substates instead. Fr fr.

๐ŸŒธ ENVIRONMENT ๐ŸŒธ

okay bestie this is the part where you find out that systemctl is constantly reading vibes from your environment variables. like it's lowkey nosy but in a helpful way ๐Ÿ’…

  • $SYSTEMD_EDITOR โ€” the editor it uses when you're editing units, and it overrides $EDITOR and $VISUAL no cap. But here's the tea: if $SYSTEMD_EDITOR isn't set, and $EDITOR isn't set, and $VISUAL isn't set โ€” or if any of them is just an empty string, or if running them straight up fails โ€” then systemctl goes down a whole list of well-known editors, in this exact order: editor(1), nano(1), vim(1), vi(1). it WILL find someone to open that file bestie ๐Ÿซถ

added in version 218, so it's been doing this for a minute.

  • $SYSTEMD_LOG_LEVEL โ€” the maximum log level of messages that get emitted. anything higher than this (meaning: less important) gets yeeted into the void. it takes a comma-separated list of values, and each value can be one of these, listed in order of decreasing importance: emerg, alert, crit, err, warning, notice, info, debug โ€” or just an integer from 0 to 7. check syslog(3) if you want the lore. each value can optionally be prefixed with one of console, syslog, kmsg, or journal, followed by a colon, to set the max level for that specific log target only (for example, SYSTEMD_LOG_LEVEL=debug,console:info means log at debug level except when logging to the console, which should be info level). โš ๏ธ but heads up: the global maximum log level takes priority over any per-target maximum log levels. global stays winning ๐Ÿ‘‘
  • $SYSTEMD_LOG_COLOR โ€” a boolean. if true, messages written to the tty get colored based on priority. ๐ŸŒˆ

ngl this one only matters when messages are going directly to the terminal, because journalctl(1) and other tools that display logs will color messages based on log level on their own. they don't need your help bestie.

  • $SYSTEMD_LOG_TIME โ€” a boolean. if true, console log messages get prefixed with a timestamp. โฐ

same deal as above: only useful when messages are written directly to the terminal or a file, because journalctl(1) and friends attach timestamps based on the entry metadata all by themselves.

  • $SYSTEMD_LOG_LOCATION โ€” a boolean. if true, messages get prefixed with a filename and line number showing where in the source code the message came from. it's giving "tag yourself" energy ๐Ÿ”

note that the log location is often attached as metadata to journal entries anyway. but including it directly in the message text can still be convenient when you're debugging programs.

  • $SYSTEMD_LOG_TARGET โ€” where the log messages go. pick one:
    • console โ€” log to the attached tty
    • console-prefixed โ€” log to the attached tty but with prefixes encoding the log level and "facility", see syslog(3)
    • kmsg โ€” log to the kernel circular log buffer
    • journal โ€” log to the journal
    • journal-or-kmsg โ€” log to the journal if available, and to kmsg otherwise
    • auto โ€” determine the appropriate log target automatically, this is the default
    • null โ€” disable log output entirely, silence, peace and quiet ๐Ÿคซ
  • $SYSTEMD_PAGER, $PAGER โ€” which pager to use when --no-pager isn't given. $SYSTEMD_PAGER wins if it's set; otherwise $PAGER gets used. if neither is set, it tries a bunch of well-known pager implementations in turn โ€” including less(1) and more(1) โ€” until one is found. if no pager implementation is discovered at all, no pager is invoked, we just rawdog the output. setting either of those variables to an empty string or to the value "cat" is equivalent to passing --no-pager.
โš ๏ธ Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER and $PAGER can only be used to disable the pager (with "cat" or ""), and are otherwise ignored. them's the rules.
  • $SYSTEMD_LESS โ€” overrides the options passed to less (by default that's "FRSXMK"). โœจ

users might wanna change two options in particular:

  • K โ€” this option instructs the pager to exit immediately when Ctrl+C is pressed. to let less handle Ctrl+C itself so it switches back to the pager command prompt instead, unset this option.

if the value of $SYSTEMD_LESS does not include "K", and the pager that gets invoked is less, then Ctrl+C will be ignored by the executable, and needs to be handled by the pager.

  • X โ€” this option instructs the pager to not send termcap initialization and deinitialization strings to the terminal. it's set by default so that command output stays visible in the terminal even after the pager exits. but โ€” and this is the tradeoff bestie โ€” it prevents some pager functionality from working, in particular paged output cannot be scrolled with the mouse. ๐Ÿ–ฑ๏ธ๐Ÿ’”
note that setting the regular $LESS environment variable has no effect for less invocations by systemd tools.

see less(1) for more discussion.

  • $SYSTEMD_LESSCHARSET โ€” overrides the charset passed to less (by default "utf-8", if the invoking terminal is determined to be UTF-8 compatible). ๐Ÿฆ‹
note that setting the regular $LESSCHARSET environment variable has no effect for less invocations by systemd tools.
  • $SYSTEMD_PAGERSECURE โ€” okay so this one is the serious one, sit up straight ๐Ÿ’€

common pager commands like less(1), in addition to "paging" โ€” i.e. scrolling through the output โ€” also support opening or writing to other files and running arbitrary shell commands. when commands are invoked with elevated privileges, for example under sudo(8) or pkexec(1), the pager becomes a security boundary. care must be taken that only programs with strictly limited functionality are used as pagers, and that unintended interactive features like opening or creating new files or starting subprocesses are not allowed. "secure mode" for the pager may be enabled as described below, if the pager supports it (most pagers are not written in a way that takes this into consideration). it is recommended to either explicitly enable "secure mode" or to completely disable the pager using --no-pager or PAGER=cat when allowing untrusted users to execute commands with elevated privileges.

this option takes a boolean argument. when set to true, the "secure mode" of the pager is enabled. in "secure mode", LESSSECURE=1 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses. currently only less(1) is known to understand this variable and implement "secure mode".

when set to false, no limitation is placed on the pager. setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited environment may allow the user to invoke arbitrary commands. ๐Ÿ”ฅ (dangerous, not cute)

when $SYSTEMD_PAGERSECURE is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it. "secure mode" is enabled if the effective UID is not the same as the owner of the login session โ€” see geteuid(2) and sd_pid_get_owner_uid(3) โ€” or when running under sudo(8) or similar tools ($SUDO_UID is set [4]). in those cases, SYSTEMD_PAGERSECURE=1 will be set and pagers which are not known to implement "secure mode" will not be used at all. note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as a convenience. it is recommended to explicitly set $SYSTEMD_PAGERSECURE or disable the pager.

note that if the $SYSTEMD_PAGER or $PAGER variables are to be honoured โ€” other than to disable the pager โ€” $SYSTEMD_PAGERSECURE must be set too.
  • $SYSTEMD_COLORS โ€” takes a boolean argument, or a special value. by default (unset), systemd and related utilities will use colors in their output if possible. if $COLORTERM is set to "truecolor" or "24bit", 24-bit colors will be enabled, 256 colors otherwise, unless $NO_COLOR or $TERM indicates colors are disabled. ๐ŸŽจ
    • true โ€” same as unset, except that $NO_COLOR is ignored.
    • false โ€” the output will be monochrome. sad beige terminal ๐Ÿ˜ญ
    • "16", "256", "24bit" โ€” always use the base 16 ANSI colors, 256 colors, or 24 bit color, respectively.
    • "auto-16", "auto-256", "auto-24bit" โ€” use the given quantity of colours, subject to $TERM, and what the console is connected to.
  • $SYSTEMD_URLIFY โ€” the value must be a boolean. controls whether clickable links should be generated in the output, for terminal emulators that support that. this can be specified to override the decision that systemd makes based on $TERM and other conditions. ๐Ÿ”—โœจ

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

systemd(1), journalctl(1), loginctl(1), machinectl(1), systemd.unit(5), systemd.resource-control(5), systemd.special(7), wall(1), systemd.preset(5), systemd.generator(7), glob(7)

like a whole friend group fr fr ๐Ÿซถ go read them, they're all icons.


๐Ÿ“ NOTES ๐Ÿ“

  1. UAPI.1 Boot Loader Specification https://uapi-group.org/specifications/specs/boot_loader_specification
  2. UAPI.2 Discoverable Partitions Specification https://uapi-group.org/specifications/specs/discoverable_partitions_specification
  3. LSB 3.0.0 http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
  4. It is recommended for other tools to set and check $SUDO_UID as appropriate, treating it as a common interface.

and that's the whole page bestie, you read ALL of it, main character behavior honestly ๐Ÿ’…โœจ this beauty ships as systemd 262.1, dated SYSTEMCTL(1) โ€” so if you ever forget which version you're on, just hit up the footer like it's a lil signature. now go forth and systemctl responsibly, ily, bye ๐ŸŽ€๐Ÿฆ‹๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms