1SYSTEMD-ANALYZE(1) systemd-analyze SYSTEMD-ANALYZE(1)
2
3
4
6 systemd-analyze - Analyze and debug system manager
7
9 systemd-analyze [OPTIONS...] [time]
10
11 systemd-analyze [OPTIONS...] blame
12
13 systemd-analyze [OPTIONS...] critical-chain [UNIT...]
14
15 systemd-analyze [OPTIONS...] dump [PATTERN...]
16
17 systemd-analyze [OPTIONS...] plot [>file.svg]
18
19 systemd-analyze [OPTIONS...] dot [PATTERN...] [>file.dot]
20
21 systemd-analyze [OPTIONS...] unit-files
22
23 systemd-analyze [OPTIONS...] unit-paths
24
25 systemd-analyze [OPTIONS...] exit-status [STATUS...]
26
27 systemd-analyze [OPTIONS...] capability [CAPABILITY...]
28
29 systemd-analyze [OPTIONS...] condition CONDITION...
30
31 systemd-analyze [OPTIONS...] syscall-filter [SET...]
32
33 systemd-analyze [OPTIONS...] filesystems [SET...]
34
35 systemd-analyze [OPTIONS...] calendar SPEC...
36
37 systemd-analyze [OPTIONS...] timestamp TIMESTAMP...
38
39 systemd-analyze [OPTIONS...] timespan SPAN...
40
41 systemd-analyze [OPTIONS...] cat-config NAME|PATH...
42
43 systemd-analyze [OPTIONS...] compare-versions VERSION1 [OP] VERSION2
44
45 systemd-analyze [OPTIONS...] verify [FILE...]
46
47 systemd-analyze [OPTIONS...] security UNIT...
48
49 systemd-analyze [OPTIONS...] inspect-elf FILE...
50
52 systemd-analyze may be used to determine system boot-up performance
53 statistics and retrieve other state and tracing information from the
54 system and service manager, and to verify the correctness of unit
55 files. It is also used to access special functions useful for advanced
56 system manager debugging.
57
58 If no command is passed, systemd-analyze time is implied.
59
60 systemd-analyze time
61 This command prints the time spent in the kernel before userspace has
62 been reached, the time spent in the initrd before normal system
63 userspace has been reached, and the time normal system userspace took
64 to initialize. Note that these measurements simply measure the time
65 passed up to the point where all system services have been spawned, but
66 not necessarily until they fully finished initialization or the disk is
67 idle.
68
69 Example 1. Show how long the boot took
70
71 # in a container
72 $ systemd-analyze time
73 Startup finished in 296ms (userspace)
74 multi-user.target reached after 275ms in userspace
75
76 # on a real machine
77 $ systemd-analyze time
78 Startup finished in 2.584s (kernel) + 19.176s (initrd) + 47.847s (userspace) = 1min 9.608s
79 multi-user.target reached after 47.820s in userspace
80
81 systemd-analyze blame
82 This command prints a list of all running units, ordered by the time
83 they took to initialize. This information may be used to optimize
84 boot-up times. Note that the output might be misleading as the
85 initialization of one service might be slow simply because it waits for
86 the initialization of another service to complete. Also note:
87 systemd-analyze blame doesn't display results for services with
88 Type=simple, because systemd considers such services to be started
89 immediately, hence no measurement of the initialization delays can be
90 done. Also note that this command only shows the time units took for
91 starting up, it does not show how long unit jobs spent in the execution
92 queue. In particular it shows the time units spent in "activating"
93 state, which is not defined for units such as device units that
94 transition directly from "inactive" to "active". This command hence
95 gives an impression of the performance of program code, but cannot
96 accurately reflect latency introduced by waiting for hardware and
97 similar events.
98
99 Example 2. Show which units took the most time during boot
100
101 $ systemd-analyze blame
102 32.875s pmlogger.service
103 20.905s systemd-networkd-wait-online.service
104 13.299s dev-vda1.device
105 ...
106 23ms sysroot.mount
107 11ms initrd-udevadm-cleanup-db.service
108 3ms sys-kernel-config.mount
109
110
111 systemd-analyze critical-chain [UNIT...]
112 This command prints a tree of the time-critical chain of units (for
113 each of the specified UNITs or for the default target otherwise). The
114 time after the unit is active or started is printed after the "@"
115 character. The time the unit takes to start is printed after the "+"
116 character. Note that the output might be misleading as the
117 initialization of services might depend on socket activation and
118 because of the parallel execution of units. Also, similarly to the
119 blame command, this only takes into account the time units spent in
120 "activating" state, and hence does not cover units that never went
121 through an "activating" state (such as device units that transition
122 directly from "inactive" to "active"). Moreover it does not show
123 information on jobs (and in particular not jobs that timed out).
124
125 Example 3. systemd-analyze critical-chain
126
127 $ systemd-analyze critical-chain
128 multi-user.target @47.820s
129 └─pmie.service @35.968s +548ms
130 └─pmcd.service @33.715s +2.247s
131 └─network-online.target @33.712s
132 └─systemd-networkd-wait-online.service @12.804s +20.905s
133 └─systemd-networkd.service @11.109s +1.690s
134 └─systemd-udevd.service @9.201s +1.904s
135 └─systemd-tmpfiles-setup-dev.service @7.306s +1.776s
136 └─kmod-static-nodes.service @6.976s +177ms
137 └─systemd-journald.socket
138 └─system.slice
139 └─-.slice
140
141 systemd-analyze dump [pattern...]
142 Without any parameter, this command outputs a (usually very long)
143 human-readable serialization of the complete service manager state.
144 Optional glob pattern may be specified, causing the output to be
145 limited to units whose names match one of the patterns. The output
146 format is subject to change without notice and should not be parsed by
147 applications. This command is rate limited for unprivileged users.
148
149 Example 4. Show the internal state of user manager
150
151 $ systemd-analyze --user dump
152 Timestamp userspace: Thu 2019-03-14 23:28:07 CET
153 Timestamp finish: Thu 2019-03-14 23:28:07 CET
154 Timestamp generators-start: Thu 2019-03-14 23:28:07 CET
155 Timestamp generators-finish: Thu 2019-03-14 23:28:07 CET
156 Timestamp units-load-start: Thu 2019-03-14 23:28:07 CET
157 Timestamp units-load-finish: Thu 2019-03-14 23:28:07 CET
158 -> Unit proc-timer_list.mount:
159 Description: /proc/timer_list
160 ...
161 -> Unit default.target:
162 Description: Main user target
163 ...
164
165 systemd-analyze plot
166 This command prints either an SVG graphic, detailing which system
167 services have been started at what time, highlighting the time they
168 spent on initialization, or the raw time data in JSON or table format.
169
170 Example 5. Plot a bootchart
171
172 $ systemd-analyze plot >bootup.svg
173 $ eog bootup.svg&
174
175 Note that this plot is based on the most recent per-unit timing data of
176 loaded units. This means that if a unit gets started, then stopped and
177 then started again the information shown will cover the most recent
178 start cycle, not the first one. Thus it's recommended to consult this
179 information only shortly after boot, so that this distinction doesn't
180 matter. Moreover, units that are not referenced by any other unit
181 through a dependency might be unloaded by the service manager once they
182 terminate (and did not fail). Such units will not show up in the plot.
183
184 systemd-analyze dot [pattern...]
185 This command generates textual dependency graph description in dot
186 format for further processing with the GraphViz dot(1) tool. Use a
187 command line like systemd-analyze dot | dot -Tsvg >systemd.svg to
188 generate a graphical dependency tree. Unless --order or --require is
189 passed, the generated graph will show both ordering and requirement
190 dependencies. Optional pattern globbing style specifications (e.g.
191 *.target) may be given at the end. A unit dependency is included in the
192 graph if any of these patterns match either the origin or destination
193 node.
194
195 Example 6. Plot all dependencies of any unit whose name starts with
196 "avahi-daemon"
197
198 $ systemd-analyze dot 'avahi-daemon.*' | dot -Tsvg >avahi.svg
199 $ eog avahi.svg
200
201 Example 7. Plot the dependencies between all known target units
202
203 $ systemd-analyze dot --to-pattern='*.target' --from-pattern='*.target' \
204 | dot -Tsvg >targets.svg
205 $ eog targets.svg
206
207 systemd-analyze unit-paths
208 This command outputs a list of all directories from which unit files,
209 .d overrides, and .wants, .requires symlinks may be loaded. Combine
210 with --user to retrieve the list for the user manager instance, and
211 --global for the global configuration of user manager instances.
212
213 Example 8. Show all paths for generated units
214
215 $ systemd-analyze unit-paths | grep '^/run'
216 /run/systemd/system.control
217 /run/systemd/transient
218 /run/systemd/generator.early
219 /run/systemd/system
220 /run/systemd/system.attached
221 /run/systemd/generator
222 /run/systemd/generator.late
223
224 Note that this verb prints the list that is compiled into
225 systemd-analyze itself, and does not communicate with the running
226 manager. Use
227
228 systemctl [--user] [--global] show -p UnitPath --value
229
230 to retrieve the actual list that the manager uses, with any empty
231 directories omitted.
232
233 systemd-analyze exit-status [STATUS...]
234 This command prints a list of exit statuses along with their "class",
235 i.e. the source of the definition (one of "glibc", "systemd", "LSB", or
236 "BSD"), see the Process Exit Codes section in systemd.exec(5). If no
237 additional arguments are specified, all known statuses are shown.
238 Otherwise, only the definitions for the specified codes are shown.
239
240 Example 9. Show some example exit status names
241
242 $ systemd-analyze exit-status 0 1 {63..65}
243 NAME STATUS CLASS
244 SUCCESS 0 glibc
245 FAILURE 1 glibc
246 - 63 -
247 USAGE 64 BSD
248 DATAERR 65 BSD
249
250 systemd-analyze capability [CAPABILITY...]
251 This command prints a list of Linux capabilities along with their
252 numeric IDs. See capabilities(7) for details. If no argument is
253 specified the full list of capabilities known to the service manager
254 and the kernel is shown. Capabilities defined by the kernel but not
255 known to the service manager are shown as "cap_???". Optionally, if
256 arguments are specified they may refer to specific cabilities by name
257 or numeric ID, in which case only the indicated capabilities are shown
258 in the table.
259
260 Example 10. Show some example capability names
261
262 $ systemd-analyze capability 0 1 {30..32}
263 NAME NUMBER
264 cap_chown 0
265 cap_dac_override 1
266 cap_audit_control 30
267 cap_setfcap 31
268 cap_mac_override 32
269
270 systemd-analyze condition CONDITION...
271 This command will evaluate Condition*=... and Assert*=...
272 assignments, and print their values, and the resulting value of the
273 combined condition set. See systemd.unit(5) for a list of available
274 conditions and asserts.
275
276 Example 11. Evaluate conditions that check kernel versions
277
278 $ systemd-analyze condition 'ConditionKernelVersion = ! <4.0' \
279 'ConditionKernelVersion = >=5.1' \
280 'ConditionACPower=|false' \
281 'ConditionArchitecture=|!arm' \
282 'AssertPathExists=/etc/os-release'
283 test.service: AssertPathExists=/etc/os-release succeeded.
284 Asserts succeeded.
285 test.service: ConditionArchitecture=|!arm succeeded.
286 test.service: ConditionACPower=|false failed.
287 test.service: ConditionKernelVersion=>=5.1 succeeded.
288 test.service: ConditionKernelVersion=!<4.0 succeeded.
289 Conditions succeeded.
290
291 systemd-analyze syscall-filter [SET...]
292 This command will list system calls contained in the specified system
293 call set SET, or all known sets if no sets are specified. Argument SET
294 must include the "@" prefix.
295
296 systemd-analyze filesystems [SET...]
297 This command will list filesystems in the specified filesystem set SET,
298 or all known sets if no sets are specified. Argument SET must include
299 the "@" prefix.
300
301 systemd-analyze calendar EXPRESSION...
302 This command will parse and normalize repetitive calendar time events,
303 and will calculate when they elapse next. This takes the same input as
304 the OnCalendar= setting in systemd.timer(5), following the syntax
305 described in systemd.time(7). By default, only the next time the
306 calendar expression will elapse is shown; use --iterations= to show the
307 specified number of next times the expression elapses. Each time the
308 expression elapses forms a timestamp, see the timestamp verb below.
309
310 Example 12. Show leap days in the near future
311
312 $ systemd-analyze calendar --iterations=5 '*-2-29 0:0:0'
313 Original form: *-2-29 0:0:0
314 Normalized form: *-02-29 00:00:00
315 Next elapse: Sat 2020-02-29 00:00:00 UTC
316 From now: 11 months 15 days left
317 Iter. #2: Thu 2024-02-29 00:00:00 UTC
318 From now: 4 years 11 months left
319 Iter. #3: Tue 2028-02-29 00:00:00 UTC
320 From now: 8 years 11 months left
321 Iter. #4: Sun 2032-02-29 00:00:00 UTC
322 From now: 12 years 11 months left
323 Iter. #5: Fri 2036-02-29 00:00:00 UTC
324 From now: 16 years 11 months left
325
326 systemd-analyze timestamp TIMESTAMP...
327 This command parses a timestamp (i.e. a single point in time) and
328 outputs the normalized form and the difference between this timestamp
329 and now. The timestamp should adhere to the syntax documented in
330 systemd.time(7), section "PARSING TIMESTAMPS".
331
332 Example 13. Show parsing of timestamps
333
334 $ systemd-analyze timestamp yesterday now tomorrow
335 Original form: yesterday
336 Normalized form: Mon 2019-05-20 00:00:00 CEST
337 (in UTC): Sun 2019-05-19 22:00:00 UTC
338 UNIX seconds: @15583032000
339 From now: 1 day 9h ago
340
341 Original form: now
342 Normalized form: Tue 2019-05-21 09:48:39 CEST
343 (in UTC): Tue 2019-05-21 07:48:39 UTC
344 UNIX seconds: @1558424919.659757
345 From now: 43us ago
346
347 Original form: tomorrow
348 Normalized form: Wed 2019-05-22 00:00:00 CEST
349 (in UTC): Tue 2019-05-21 22:00:00 UTC
350 UNIX seconds: @15584760000
351 From now: 14h left
352
353 systemd-analyze timespan EXPRESSION...
354 This command parses a time span (i.e. a difference between two
355 timestamps) and outputs the normalized form and the equivalent value in
356 microseconds. The time span should adhere to the syntax documented in
357 systemd.time(7), section "PARSING TIME SPANS". Values without units are
358 parsed as seconds.
359
360 Example 14. Show parsing of timespans
361
362 $ systemd-analyze timespan 1s 300s '1year 0.000001s'
363 Original: 1s
364 μs: 1000000
365 Human: 1s
366
367 Original: 300s
368 μs: 300000000
369 Human: 5min
370
371 Original: 1year 0.000001s
372 μs: 31557600000001
373 Human: 1y 1us
374
375 systemd-analyze cat-config NAME|PATH...
376 This command is similar to systemctl cat, but operates on config files.
377 It will copy the contents of a config file and any drop-ins to standard
378 output, using the usual systemd set of directories and rules for
379 precedence. Each argument must be either an absolute path including the
380 prefix (such as /etc/systemd/logind.conf or
381 /usr/lib/systemd/logind.conf), or a name relative to the prefix (such
382 as systemd/logind.conf).
383
384 Example 15. Showing logind configuration
385
386 $ systemd-analyze cat-config systemd/logind.conf
387 # /etc/systemd/logind.conf
388 ...
389 [Login]
390 NAutoVTs=8
391 ...
392
393 # /usr/lib/systemd/logind.conf.d/20-test.conf
394 ... some override from another package
395
396 # /etc/systemd/logind.conf.d/50-override.conf
397 ... some administrator override
398
399
400 systemd-analyze compare-versions VERSION1 [OP] VERSION2
401 This command has two distinct modes of operation, depending on whether
402 the operator OP is specified.
403
404 In the first mode — when OP is not specified — it will compare the two
405 version strings and print either "VERSION1 < VERSION2", or "VERSION1 ==
406 VERSION2", or "VERSION1 > VERSION2" as appropriate.
407
408 The exit status is 0 if the versions are equal, 11 if the version of
409 the right is smaller, and 12 if the version of the left is smaller.
410 (This matches the convention used by rpmdev-vercmp.)
411
412 In the second mode — when OP is specified — it will compare the two
413 version strings using the operation OP and return 0 (success) if they
414 condition is satisfied, and 1 (failure) otherwise. OP may be lt, le,
415 eq, ne, ge, gt. In this mode, no output is printed. (This matches the
416 convention used by dpkg(1) --compare-versions.)
417
418 Example 16. Compare versions of a package
419
420 $ systemd-analyze compare-versions systemd-250~rc1.fc36.aarch64 systemd-251.fc36.aarch64
421 systemd-250~rc1.fc36.aarch64 < systemd-251.fc36.aarch64
422 $ echo $?
423 12
424
425 $ systemd-analyze compare-versions 1 lt 2; echo $?
426 0
427 $ systemd-analyze compare-versions 1 ge 2; echo $?
428 1
429
430
431 systemd-analyze verify FILE...
432 This command will load unit files and print warnings if any errors are
433 detected. Files specified on the command line will be loaded, but also
434 any other units referenced by them. A unit's name on disk can be
435 overridden by specifying an alias after a colon; see below for an
436 example. The full unit search path is formed by combining the
437 directories for all command line arguments, and the usual unit load
438 paths. The variable $SYSTEMD_UNIT_PATH is supported, and may be used to
439 replace or augment the compiled in set of unit load paths; see
440 systemd.unit(5). All units files present in the directories containing
441 the command line arguments will be used in preference to the other
442 paths.
443
444 The following errors are currently detected:
445
446 • unknown sections and directives,
447
448 • missing dependencies which are required to start the given unit,
449
450 • man pages listed in Documentation= which are not found in the
451 system,
452
453 • commands listed in ExecStart= and similar which are not found in
454 the system or not executable.
455
456 Example 17. Misspelt directives
457
458 $ cat ./user.slice
459 [Unit]
460 WhatIsThis=11
461 Documentation=man:nosuchfile(1)
462 Requires=different.service
463
464 [Service]
465 Description=x
466
467 $ systemd-analyze verify ./user.slice
468 [./user.slice:9] Unknown lvalue 'WhatIsThis' in section 'Unit'
469 [./user.slice:13] Unknown section 'Service'. Ignoring.
470 Error: org.freedesktop.systemd1.LoadFailed:
471 Unit different.service failed to load:
472 No such file or directory.
473 Failed to create user.slice/start: Invalid argument
474 user.slice: man nosuchfile(1) command failed with code 16
475
476
477 Example 18. Missing service units
478
479 $ tail ./a.socket ./b.socket
480 ==> ./a.socket <==
481 [Socket]
482 ListenStream=100
483
484 ==> ./b.socket <==
485 [Socket]
486 ListenStream=100
487 Accept=yes
488
489 $ systemd-analyze verify ./a.socket ./b.socket
490 Service a.service not loaded, a.socket cannot be started.
491 Service b@0.service not loaded, b.socket cannot be started.
492
493
494 Example 19. Aliasing a unit
495
496 $ cat /tmp/source
497 [Unit]
498 Description=Hostname printer
499
500 [Service]
501 Type=simple
502 ExecStart=/usr/bin/echo %H
503 MysteryKey=true
504
505 $ systemd-analyze verify /tmp/source
506 Failed to prepare filename /tmp/source: Invalid argument
507
508 $ systemd-analyze verify /tmp/source:alias.service
509 /tmp/systemd-analyze-XXXXXX/alias.service:7: Unknown key name 'MysteryKey' in section 'Service', ignoring.
510
511
512 systemd-analyze security [UNIT...]
513 This command analyzes the security and sandboxing settings of one or
514 more specified service units. If at least one unit name is specified
515 the security settings of the specified service units are inspected and
516 a detailed analysis is shown. If no unit name is specified, all
517 currently loaded, long-running service units are inspected and a terse
518 table with results shown. The command checks for various
519 security-related service settings, assigning each a numeric "exposure
520 level" value, depending on how important a setting is. It then
521 calculates an overall exposure level for the whole unit, which is an
522 estimation in the range 0.0...10.0 indicating how exposed a service is
523 security-wise. High exposure levels indicate very little applied
524 sandboxing. Low exposure levels indicate tight sandboxing and strongest
525 security restrictions. Note that this only analyzes the per-service
526 security features systemd itself implements. This means that any
527 additional security mechanisms applied by the service code itself are
528 not accounted for. The exposure level determined this way should not be
529 misunderstood: a high exposure level neither means that there is no
530 effective sandboxing applied by the service code itself, nor that the
531 service is actually vulnerable to remote or local attacks. High
532 exposure levels do indicate however that most likely the service might
533 benefit from additional settings applied to them.
534
535 Please note that many of the security and sandboxing settings
536 individually can be circumvented — unless combined with others. For
537 example, if a service retains the privilege to establish or undo mount
538 points many of the sandboxing options can be undone by the service code
539 itself. Due to that is essential that each service uses the most
540 comprehensive and strict sandboxing and security settings possible. The
541 tool will take into account some of these combinations and
542 relationships between the settings, but not all. Also note that the
543 security and sandboxing settings analyzed here only apply to the
544 operations executed by the service code itself. If a service has access
545 to an IPC system (such as D-Bus) it might request operations from other
546 services that are not subject to the same restrictions. Any
547 comprehensive security and sandboxing analysis is hence incomplete if
548 the IPC access policy is not validated too.
549
550 Example 20. Analyze systemd-logind.service
551
552 $ systemd-analyze security --no-pager systemd-logind.service
553 NAME DESCRIPTION EXPOSURE
554 ✗ PrivateNetwork= Service has access to the host's network 0.5
555 ✗ User=/DynamicUser= Service runs as root user 0.4
556 ✗ DeviceAllow= Service has no device ACL 0.2
557 ✓ IPAddressDeny= Service blocks all IP address ranges
558 ...
559 → Overall exposure level for systemd-logind.service: 4.1 OK 🙂
560
561 systemd-analyze inspect-elf FILE...
562 This command will load the specified files, and if they are ELF objects
563 (executables, libraries, core files, etc.) it will parse the embedded
564 packaging metadata, if any, and print it in a table or json format. See
565 the Packaging Metadata[1] documentation for more information.
566
567 Example 21. Table output
568
569 $ systemd-analyze inspect-elf --json=pretty /tmp/core.fsverity.1000.f77dac5dc161402aa44e15b7dd9dcf97.58561.1637106137000000
570 {
571 "elfType" : "coredump",
572 "elfArchitecture" : "AMD x86-64",
573 "/home/bluca/git/fsverity-utils/fsverity" : {
574 "type" : "deb",
575 "name" : "fsverity-utils",
576 "version" : "1.3-1",
577 "buildId" : "7c895ecd2a271f93e96268f479fdc3c64a2ec4ee"
578 },
579 "/home/bluca/git/fsverity-utils/libfsverity.so.0" : {
580 "type" : "deb",
581 "name" : "fsverity-utils",
582 "version" : "1.3-1",
583 "buildId" : "b5e428254abf14237b0ae70ed85fffbb98a78f88"
584 }
585 }
586
587
589 The following options are understood:
590
591 --system
592 Operates on the system systemd instance. This is the implied
593 default.
594
595 --user
596 Operates on the user systemd instance.
597
598 --global
599 Operates on the system-wide configuration for user systemd
600 instance.
601
602 --order, --require
603 When used in conjunction with the dot command (see above), selects
604 which dependencies are shown in the dependency graph. If --order is
605 passed, only dependencies of type After= or Before= are shown. If
606 --require is passed, only dependencies of type Requires=,
607 Requisite=, Wants= and Conflicts= are shown. If neither is passed,
608 this shows dependencies of all these types.
609
610 --from-pattern=, --to-pattern=
611 When used in conjunction with the dot command (see above), this
612 selects which relationships are shown in the dependency graph. Both
613 options require a glob(7) pattern as an argument, which will be
614 matched against the left-hand and the right-hand, respectively,
615 nodes of a relationship.
616
617 Each of these can be used more than once, in which case the unit
618 name must match one of the values. When tests for both sides of the
619 relation are present, a relation must pass both tests to be shown.
620 When patterns are also specified as positional arguments, they must
621 match at least one side of the relation. In other words, patterns
622 specified with those two options will trim the list of edges
623 matched by the positional arguments, if any are given, and fully
624 determine the list of edges shown otherwise.
625
626 --fuzz=timespan
627 When used in conjunction with the critical-chain command (see
628 above), also show units, which finished timespan earlier, than the
629 latest unit in the same level. The unit of timespan is seconds
630 unless specified with a different unit, e.g. "50ms".
631
632 --man=no
633 Do not invoke man(1) to verify the existence of man pages listed in
634 Documentation=.
635
636 --generators
637 Invoke unit generators, see systemd.generator(7). Some generators
638 require root privileges. Under a normal user, running with
639 generators enabled will generally result in some warnings.
640
641 --recursive-errors=MODE
642 Control verification of units and their dependencies and whether
643 systemd-analyze verify exits with a non-zero process exit status or
644 not. With yes, return a non-zero process exit status when warnings
645 arise during verification of either the specified unit or any of
646 its associated dependencies. With no, return a non-zero process
647 exit status when warnings arise during verification of only the
648 specified unit. With one, return a non-zero process exit status
649 when warnings arise during verification of either the specified
650 unit or its immediate dependencies. If this option is not
651 specified, zero is returned as the exit status regardless whether
652 warnings arise during verification or not.
653
654 --root=PATH
655 With cat-files and verify, operate on files underneath the
656 specified root path PATH.
657
658 --image=PATH
659 With cat-files and verify, operate on files inside the specified
660 image path PATH.
661
662 --offline=BOOL
663 With security, perform an offline security review of the specified
664 unit files, i.e. does not have to rely on PID 1 to acquire security
665 information for the files like the security verb when used by
666 itself does. This means that --offline= can be used with --root=
667 and --image= as well. If a unit's overall exposure level is above
668 that set by --threshold= (default value is 100), --offline= will
669 return an error.
670
671 --profile=PATH
672 With security --offline=, takes into consideration the specified
673 portable profile when assessing unit settings. The profile can be
674 passed by name, in which case the well-known system locations will
675 be searched, or it can be the full path to a specific drop-in file.
676
677 --threshold=NUMBER
678 With security, allow the user to set a custom value to compare the
679 overall exposure level with, for the specified unit files. If a
680 unit's overall exposure level, is greater than that set by the
681 user, security will return an error. --threshold= can be used with
682 --offline= as well and its default value is 100.
683
684 --security-policy=PATH
685 With security, allow the user to define a custom set of
686 requirements formatted as a JSON file against which to compare the
687 specified unit file(s) and determine their overall exposure level
688 to security threats.
689
690 Table 1. Accepted Assessment Test Identifiers
691 ┌─────────────────────────────────────────────────────────┐
692 │Assessment Test Identifier │
693 ├─────────────────────────────────────────────────────────┤
694 │UserOrDynamicUser │
695 ├─────────────────────────────────────────────────────────┤
696 │SupplementaryGroups │
697 ├─────────────────────────────────────────────────────────┤
698 │PrivateMounts │
699 ├─────────────────────────────────────────────────────────┤
700 │PrivateDevices │
701 ├─────────────────────────────────────────────────────────┤
702 │PrivateTmp │
703 ├─────────────────────────────────────────────────────────┤
704 │PrivateNetwork │
705 ├─────────────────────────────────────────────────────────┤
706 │PrivateUsers │
707 ├─────────────────────────────────────────────────────────┤
708 │ProtectControlGroups │
709 ├─────────────────────────────────────────────────────────┤
710 │ProtectKernelModules │
711 ├─────────────────────────────────────────────────────────┤
712 │ProtectKernelTunables │
713 ├─────────────────────────────────────────────────────────┤
714 │ProtectKernelLogs │
715 ├─────────────────────────────────────────────────────────┤
716 │ProtectClock │
717 ├─────────────────────────────────────────────────────────┤
718 │ProtectHome │
719 ├─────────────────────────────────────────────────────────┤
720 │ProtectHostname │
721 ├─────────────────────────────────────────────────────────┤
722 │ProtectSystem │
723 ├─────────────────────────────────────────────────────────┤
724 │RootDirectoryOrRootImage │
725 ├─────────────────────────────────────────────────────────┤
726 │LockPersonality │
727 ├─────────────────────────────────────────────────────────┤
728 │MemoryDenyWriteExecute │
729 ├─────────────────────────────────────────────────────────┤
730 │NoNewPrivileges │
731 ├─────────────────────────────────────────────────────────┤
732 │CapabilityBoundingSet_CAP_SYS_ADMIN │
733 ├─────────────────────────────────────────────────────────┤
734 │CapabilityBoundingSet_CAP_SET_UID_GID_PCAP │
735 ├─────────────────────────────────────────────────────────┤
736 │CapabilityBoundingSet_CAP_SYS_PTRACE │
737 ├─────────────────────────────────────────────────────────┤
738 │CapabilityBoundingSet_CAP_SYS_TIME │
739 ├─────────────────────────────────────────────────────────┤
740 │CapabilityBoundingSet_CAP_NET_ADMIN │
741 ├─────────────────────────────────────────────────────────┤
742 │CapabilityBoundingSet_CAP_SYS_RAWIO │
743 ├─────────────────────────────────────────────────────────┤
744 │CapabilityBoundingSet_CAP_SYS_MODULE │
745 ├─────────────────────────────────────────────────────────┤
746 │CapabilityBoundingSet_CAP_AUDIT │
747 ├─────────────────────────────────────────────────────────┤
748 │CapabilityBoundingSet_CAP_SYSLOG │
749 ├─────────────────────────────────────────────────────────┤
750 │CapabilityBoundingSet_CAP_SYS_NICE_RESOURCE │
751 ├─────────────────────────────────────────────────────────┤
752 │CapabilityBoundingSet_CAP_MKNOD │
753 ├─────────────────────────────────────────────────────────┤
754 │CapabilityBoundingSet_CAP_CHOWN_FSETID_SETFCAP │
755 ├─────────────────────────────────────────────────────────┤
756 │CapabilityBoundingSet_CAP_DAC_FOWNER_IPC_OWNER │
757 ├─────────────────────────────────────────────────────────┤
758 │CapabilityBoundingSet_CAP_KILL │
759 ├─────────────────────────────────────────────────────────┤
760 │CapabilityBoundingSet_CAP_NET_BIND_SERVICE_BROADCAST_RAW │
761 ├─────────────────────────────────────────────────────────┤
762 │CapabilityBoundingSet_CAP_SYS_BOOT │
763 ├─────────────────────────────────────────────────────────┤
764 │CapabilityBoundingSet_CAP_MAC │
765 ├─────────────────────────────────────────────────────────┤
766 │CapabilityBoundingSet_CAP_LINUX_IMMUTABLE │
767 ├─────────────────────────────────────────────────────────┤
768 │CapabilityBoundingSet_CAP_IPC_LOCK │
769 ├─────────────────────────────────────────────────────────┤
770 │CapabilityBoundingSet_CAP_SYS_CHROOT │
771 ├─────────────────────────────────────────────────────────┤
772 │CapabilityBoundingSet_CAP_BLOCK_SUSPEND │
773 ├─────────────────────────────────────────────────────────┤
774 │CapabilityBoundingSet_CAP_WAKE_ALARM │
775 ├─────────────────────────────────────────────────────────┤
776 │CapabilityBoundingSet_CAP_LEASE │
777 ├─────────────────────────────────────────────────────────┤
778 │CapabilityBoundingSet_CAP_SYS_TTY_CONFIG │
779 ├─────────────────────────────────────────────────────────┤
780 │CapabilityBoundingSet_CAP_BPF │
781 ├─────────────────────────────────────────────────────────┤
782 │UMask │
783 ├─────────────────────────────────────────────────────────┤
784 │KeyringMode │
785 ├─────────────────────────────────────────────────────────┤
786 │ProtectProc │
787 ├─────────────────────────────────────────────────────────┤
788 │ProcSubset │
789 ├─────────────────────────────────────────────────────────┤
790 │NotifyAccess │
791 ├─────────────────────────────────────────────────────────┤
792 │RemoveIPC │
793 ├─────────────────────────────────────────────────────────┤
794 │Delegate │
795 ├─────────────────────────────────────────────────────────┤
796 │RestrictRealtime │
797 ├─────────────────────────────────────────────────────────┤
798 │RestrictSUIDSGID │
799 ├─────────────────────────────────────────────────────────┤
800 │RestrictNamespaces_user │
801 ├─────────────────────────────────────────────────────────┤
802 │RestrictNamespaces_mnt │
803 ├─────────────────────────────────────────────────────────┤
804 │RestrictNamespaces_ipc │
805 ├─────────────────────────────────────────────────────────┤
806 │RestrictNamespaces_pid │
807 ├─────────────────────────────────────────────────────────┤
808 │RestrictNamespaces_cgroup │
809 ├─────────────────────────────────────────────────────────┤
810 │RestrictNamespaces_uts │
811 ├─────────────────────────────────────────────────────────┤
812 │RestrictNamespaces_net │
813 ├─────────────────────────────────────────────────────────┤
814 │RestrictAddressFamilies_AF_INET_INET6 │
815 ├─────────────────────────────────────────────────────────┤
816 │RestrictAddressFamilies_AF_UNIX │
817 ├─────────────────────────────────────────────────────────┤
818 │RestrictAddressFamilies_AF_NETLINK │
819 ├─────────────────────────────────────────────────────────┤
820 │RestrictAddressFamilies_AF_PACKET │
821 ├─────────────────────────────────────────────────────────┤
822 │RestrictAddressFamilies_OTHER │
823 ├─────────────────────────────────────────────────────────┤
824 │SystemCallArchitectures │
825 ├─────────────────────────────────────────────────────────┤
826 │SystemCallFilter_swap │
827 ├─────────────────────────────────────────────────────────┤
828 │SystemCallFilter_obsolete │
829 ├─────────────────────────────────────────────────────────┤
830 │SystemCallFilter_clock │
831 ├─────────────────────────────────────────────────────────┤
832 │SystemCallFilter_cpu_emulation │
833 ├─────────────────────────────────────────────────────────┤
834 │SystemCallFilter_debug │
835 ├─────────────────────────────────────────────────────────┤
836 │SystemCallFilter_mount │
837 ├─────────────────────────────────────────────────────────┤
838 │SystemCallFilter_module │
839 ├─────────────────────────────────────────────────────────┤
840 │SystemCallFilter_raw_io │
841 ├─────────────────────────────────────────────────────────┤
842 │SystemCallFilter_reboot │
843 ├─────────────────────────────────────────────────────────┤
844 │SystemCallFilter_privileged │
845 ├─────────────────────────────────────────────────────────┤
846 │SystemCallFilter_resources │
847 ├─────────────────────────────────────────────────────────┤
848 │IPAddressDeny │
849 ├─────────────────────────────────────────────────────────┤
850 │DeviceAllow │
851 ├─────────────────────────────────────────────────────────┤
852 │AmbientCapabilities │
853 └─────────────────────────────────────────────────────────┘
854 See example "JSON Policy" below.
855
856 --json=MODE
857 With the security command, generate a JSON formatted output of the
858 security analysis table. The format is a JSON array with objects
859 containing the following fields: set which indicates if the setting
860 has been enabled or not, name which is what is used to refer to the
861 setting, json_field which is the JSON compatible identifier of the
862 setting, description which is an outline of the setting state, and
863 exposure which is a number in the range 0.0...10.0, where a higher
864 value corresponds to a higher security threat. The JSON version of
865 the table is printed to standard output. The MODE passed to the
866 option can be one of three: off which is the default, pretty and
867 short which respectively output a prettified or shorted JSON
868 version of the security table. With the plot command, generate a
869 JSON formatted output of the raw time data. The format is a JSON
870 array with objects containing the following fields: name which is
871 the unit name, activated which is the time after startup the
872 service was activated, activating which is how long after startup
873 the service was initially started, time which is how long the
874 service took to activate from when it was initially started,
875 deactivated which is the time after startup that the service was
876 deactivated, deactivating which is the time after startup that the
877 service was initially told to deactivate.
878
879 --iterations=NUMBER
880 When used with the calendar command, show the specified number of
881 iterations the specified calendar expression will elapse next.
882 Defaults to 1.
883
884 --base-time=TIMESTAMP
885 When used with the calendar command, show next iterations relative
886 to the specified point in time. If not specified defaults to the
887 current time.
888
889 --unit=UNIT
890 When used with the condition command, evaluate all the
891 Condition*=... and Assert*=... assignments in the specified unit
892 file. The full unit search path is formed by combining the
893 directories for the specified unit with the usual unit load paths.
894 The variable $SYSTEMD_UNIT_PATH is supported, and may be used to
895 replace or augment the compiled in set of unit load paths; see
896 systemd.unit(5). All units files present in the directory
897 containing the specified unit will be used in preference to the
898 other paths.
899
900 --table
901 When used with the plot command, the raw time data is output in a
902 table.
903
904 --no-legend
905 When used with the plot command in combination with either --table
906 or --json=, no legends or hints are included in the output.
907
908 -H, --host=
909 Execute the operation remotely. Specify a hostname, or a username
910 and hostname separated by "@", to connect to. The hostname may
911 optionally be suffixed by a port ssh is listening on, separated by
912 ":", and then a container name, separated by "/", which connects
913 directly to a specific container on the specified host. This will
914 use SSH to talk to the remote machine manager instance. Container
915 names may be enumerated with machinectl -H HOST. Put IPv6 addresses
916 in brackets.
917
918 -M, --machine=
919 Execute operation on a local container. Specify a container name to
920 connect to, optionally prefixed by a user name to connect as and a
921 separating "@" character. If the special string ".host" is used in
922 place of the container name, a connection to the local system is
923 made (which is useful to connect to a specific user's user bus:
924 "--user --machine=lennart@.host"). If the "@" syntax is not used,
925 the connection is made as root user. If the "@" syntax is used
926 either the left hand side or the right hand side may be omitted
927 (but not both) in which case the local user name and ".host" are
928 implied.
929
930 --quiet
931 Suppress hints and other non-essential output.
932
933 -h, --help
934 Print a short help text and exit.
935
936 --version
937 Print a short version string and exit.
938
939 --no-pager
940 Do not pipe output into a pager.
941
943 For most commands, 0 is returned on success, and a non-zero failure
944 code otherwise.
945
946 With the verb compare-versions, in the two-argument form, 12, 0, 11 is
947 returned if the second version string is respectively larger, equal, or
948 smaller to the first. In the three-argument form, 0 or 1 if the
949 condition is respectively true or false.
950
952 $SYSTEMD_LOG_LEVEL
953 The maximum log level of emitted messages (messages with a higher
954 log level, i.e. less important ones, will be suppressed). Either
955 one of (in order of decreasing importance) emerg, alert, crit, err,
956 warning, notice, info, debug, or an integer in the range 0...7. See
957 syslog(3) for more information.
958
959 $SYSTEMD_LOG_COLOR
960 A boolean. If true, messages written to the tty will be colored
961 according to priority.
962
963 This setting is only useful when messages are written directly to
964 the terminal, because journalctl(1) and other tools that display
965 logs will color messages based on the log level on their own.
966
967 $SYSTEMD_LOG_TIME
968 A boolean. If true, console log messages will be prefixed with a
969 timestamp.
970
971 This setting is only useful when messages are written directly to
972 the terminal or a file, because journalctl(1) and other tools that
973 display logs will attach timestamps based on the entry metadata on
974 their own.
975
976 $SYSTEMD_LOG_LOCATION
977 A boolean. If true, messages will be prefixed with a filename and
978 line number in the source code where the message originates.
979
980 Note that the log location is often attached as metadata to journal
981 entries anyway. Including it directly in the message text can
982 nevertheless be convenient when debugging programs.
983
984 $SYSTEMD_LOG_TID
985 A boolean. If true, messages will be prefixed with the current
986 numerical thread ID (TID).
987
988 Note that the this information is attached as metadata to journal
989 entries anyway. Including it directly in the message text can
990 nevertheless be convenient when debugging programs.
991
992 $SYSTEMD_LOG_TARGET
993 The destination for log messages. One of console (log to the
994 attached tty), console-prefixed (log to the attached tty but with
995 prefixes encoding the log level and "facility", see syslog(3), kmsg
996 (log to the kernel circular log buffer), journal (log to the
997 journal), journal-or-kmsg (log to the journal if available, and to
998 kmsg otherwise), auto (determine the appropriate log target
999 automatically, the default), null (disable log output).
1000
1001 $SYSTEMD_PAGER
1002 Pager to use when --no-pager is not given; overrides $PAGER. If
1003 neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known
1004 pager implementations are tried in turn, including less(1) and
1005 more(1), until one is found. If no pager implementation is
1006 discovered no pager is invoked. Setting this environment variable
1007 to an empty string or the value "cat" is equivalent to passing
1008 --no-pager.
1009
1010 Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER (as well
1011 as $PAGER) will be silently ignored.
1012
1013 $SYSTEMD_LESS
1014 Override the options passed to less (by default "FRSXMK").
1015
1016 Users might want to change two options in particular:
1017
1018 K
1019 This option instructs the pager to exit immediately when Ctrl+C
1020 is pressed. To allow less to handle Ctrl+C itself to switch
1021 back to the pager command prompt, unset this option.
1022
1023 If the value of $SYSTEMD_LESS does not include "K", and the
1024 pager that is invoked is less, Ctrl+C will be ignored by the
1025 executable, and needs to be handled by the pager.
1026
1027 X
1028 This option instructs the pager to not send termcap
1029 initialization and deinitialization strings to the terminal. It
1030 is set by default to allow command output to remain visible in
1031 the terminal even after the pager exits. Nevertheless, this
1032 prevents some pager functionality from working, in particular
1033 paged output cannot be scrolled with the mouse.
1034
1035 See less(1) for more discussion.
1036
1037 $SYSTEMD_LESSCHARSET
1038 Override the charset passed to less (by default "utf-8", if the
1039 invoking terminal is determined to be UTF-8 compatible).
1040
1041 $SYSTEMD_PAGERSECURE
1042 Takes a boolean argument. When true, the "secure" mode of the pager
1043 is enabled; if false, disabled. If $SYSTEMD_PAGERSECURE is not set
1044 at all, secure mode is enabled if the effective UID is not the same
1045 as the owner of the login session, see geteuid(2) and
1046 sd_pid_get_owner_uid(3). In secure mode, LESSSECURE=1 will be set
1047 when invoking the pager, and the pager shall disable commands that
1048 open or create new files or start new subprocesses. When
1049 $SYSTEMD_PAGERSECURE is not set at all, pagers which are not known
1050 to implement secure mode will not be used. (Currently only less(1)
1051 implements secure mode.)
1052
1053 Note: when commands are invoked with elevated privileges, for
1054 example under sudo(8) or pkexec(1), care must be taken to ensure
1055 that unintended interactive features are not enabled. "Secure" mode
1056 for the pager may be enabled automatically as describe above.
1057 Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited
1058 environment allows the user to invoke arbitrary commands. Note that
1059 if the $SYSTEMD_PAGER or $PAGER variables are to be honoured,
1060 $SYSTEMD_PAGERSECURE must be set too. It might be reasonable to
1061 completely disable the pager using --no-pager instead.
1062
1063 $SYSTEMD_COLORS
1064 Takes a boolean argument. When true, systemd and related utilities
1065 will use colors in their output, otherwise the output will be
1066 monochrome. Additionally, the variable can take one of the
1067 following special values: "16", "256" to restrict the use of colors
1068 to the base 16 or 256 ANSI colors, respectively. This can be
1069 specified to override the automatic decision based on $TERM and
1070 what the console is connected to.
1071
1072 $SYSTEMD_URLIFY
1073 The value must be a boolean. Controls whether clickable links
1074 should be generated in the output for terminal emulators supporting
1075 this. This can be specified to override the decision that systemd
1076 makes based on $TERM and other conditions.
1077
1079 Example 22. JSON Policy
1080
1081 The JSON file passed as a path parameter to --security-policy= has a
1082 top-level JSON object, with keys being the assessment test identifiers
1083 mentioned above. The values in the file should be JSON objects with one
1084 or more of the following fields: description_na (string),
1085 description_good (string), description_bad (string), weight (unsigned
1086 integer), and range (unsigned integer). If any of these fields
1087 corresponding to a specific id of the unit file is missing from the
1088 JSON object, the default built-in field value corresponding to that
1089 same id is used for security analysis as default. The weight and range
1090 fields are used in determining the overall exposure level of the unit
1091 files: the value of each setting is assigned a badness score, which is
1092 multiplied by the policy weight and divided by the policy range to
1093 determine the overall exposure that the setting implies. The computed
1094 badness is summed across all settings in the unit file, normalized to
1095 the 1...100 range, and used to determine the overall exposure level of
1096 the unit. By allowing users to manipulate these fields, the 'security'
1097 verb gives them the option to decide for themself which ids are more
1098 important and hence should have a greater effect on the exposure level.
1099 A weight of "0" means the setting will not be checked.
1100
1101 {
1102 "PrivateDevices":
1103 {
1104 "description_good": "Service has no access to hardware devices",
1105 "description_bad": "Service potentially has access to hardware devices",
1106 "weight": 1000,
1107 "range": 1
1108 },
1109 "PrivateMounts":
1110 {
1111 "description_good": "Service cannot install system mounts",
1112 "description_bad": "Service may install system mounts",
1113 "weight": 1000,
1114 "range": 1
1115 },
1116 "PrivateNetwork":
1117 {
1118 "description_good": "Service has no access to the host's network",
1119 "description_bad": "Service has access to the host's network",
1120 "weight": 2500,
1121 "range": 1
1122 },
1123 "PrivateTmp":
1124 {
1125 "description_good": "Service has no access to other software's temporary files",
1126 "description_bad": "Service has access to other software's temporary files",
1127 "weight": 1000,
1128 "range": 1
1129 },
1130 "PrivateUsers":
1131 {
1132 "description_good": "Service does not have access to other users",
1133 "description_bad": "Service has access to other users",
1134 "weight": 1000,
1135 "range": 1
1136 }
1137 }
1138
1139
1141 systemd(1), systemctl(1)
1142
1144 1. Packaging Metadata
1145 https://systemd.io/COREDUMP_PACKAGE_METADATA/
1146
1147
1148
1149systemd 253 SYSTEMD-ANALYZE(1)