1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
<refentry id="busctl"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>busctl</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>busctl</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>busctl</refname>
<refpurpose>Introspect the bus</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>busctl</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="opt">COMMAND</arg>
<arg choice="opt" rep="repeat"><replaceable>NAME</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><command>busctl</command> may be used to
introspect and monitor the D-Bus bus.</para>
</refsect1>
<refsect1>
<title>Commands</title>
<para>The following commands are understood:</para>
<variablelist>
<varlistentry>
<term><command>list</command></term>
<listitem><para>Show all peers on the bus, by their service
names. By default, shows both unique and well-known names, but
this may be changed with the <option>--unique</option> and
<option>--acquired</option> switches. This is the default
operation if no command is specified.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>status</command> <arg choice="opt"><replaceable>SERVICE</replaceable></arg></term>
<listitem><para>Show process information and credentials of a
bus service (if one is specified by its unique or well-known
name), a process (if one is specified by its numeric PID), or
the owner of the bus (if no parameter is
specified).</para></listitem>
</varlistentry>
<varlistentry>
<term><command>monitor</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
<listitem><para>Dump messages being exchanged. If
<replaceable>SERVICE</replaceable> is specified, show messages
to or from this peer, identified by its well-known or unique
name. Otherwise, show all messages on the bus. Use
<keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo>
to terminate the dump.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>capture</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
<listitem><para>Similar to <command>monitor</command> but
writes the output in pcapng format (for details, see
<ulink url="https://github.com/pcapng/pcapng/">
PCAP Next Generation (pcapng) Capture File Format</ulink>).
Make sure to redirect standard output to a file or pipe. Tools like
<citerefentry project='die-net'><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry>
may be used to dissect and view the resulting
files.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>tree</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
<listitem><para>Shows an object tree of one or more
services. If <replaceable>SERVICE</replaceable> is specified,
show object tree of the specified services only. Otherwise,
show all object trees of all services on the bus that acquired
at least one well-known name.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>introspect</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="opt"><replaceable>INTERFACE</replaceable></arg></term>
<listitem><para>Show interfaces, methods, properties and
signals of the specified object (identified by its path) on
the specified service. If the interface argument is passed, the
output is limited to members of the specified
interface.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>call</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>METHOD</replaceable></arg> <arg choice="opt"><replaceable>SIGNATURE</replaceable> <arg choice="opt" rep="repeat"><replaceable>ARGUMENT</replaceable></arg></arg></term>
<listitem><para>Invoke a method and show the response. Takes a
service name, object path, interface name and method name. If
parameters shall be passed to the method call, a signature
string is required, followed by the arguments, individually
formatted as strings. For details on the formatting used, see
below. To suppress output of the returned data, use the
<option>--quiet</option> option.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>emit</command> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>SIGNAL</replaceable></arg> <arg choice="opt"><replaceable>SIGNATURE</replaceable> <arg choice="opt" rep="repeat"><replaceable>ARGUMENT</replaceable></arg></arg></term>
<listitem><para>Emit a signal. Takes an object path, interface name and method name. If parameters
shall be passed, a signature string is required, followed by the arguments, individually formatted as
strings. For details on the formatting used, see below. To specify the destination of the signal,
use the <option>--destination=</option> option.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>get-property</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain" rep="repeat"><replaceable>PROPERTY</replaceable></arg></term>
<listitem><para>Retrieve the current value of one or more
object properties. Takes a service name, object path,
interface name and property name. Multiple properties may be
specified at once, in which case their values will be shown one
after the other, separated by newlines. The output is, by
default, in terse format. Use <option>--verbose</option> for a
more elaborate output format.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>set-property</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>PROPERTY</replaceable></arg> <arg choice="plain"><replaceable>SIGNATURE</replaceable></arg> <arg choice="plain" rep="repeat"><replaceable>ARGUMENT</replaceable></arg></term>
<listitem><para>Set the current value of an object
property. Takes a service name, object path, interface name,
property name, property signature, followed by a list of
parameters formatted as strings.</para></listitem>
</varlistentry>
<varlistentry>
<term><command>help</command></term>
<listitem><para>Show command syntax help.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Options</title>
<para>The following options are understood:</para>
<variablelist>
<varlistentry>
<term><option>--address=<replaceable>ADDRESS</replaceable></option></term>
<listitem><para>Connect to the bus specified by
<replaceable>ADDRESS</replaceable> instead of using suitable
defaults for either the system or user bus (see
<option>--system</option> and <option>--user</option>
options).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--show-machine</option></term>
<listitem><para>When showing the list of peers, show a
column containing the names of containers they belong to.
See
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--unique</option></term>
<listitem><para>When showing the list of peers, show only
"unique" names (of the form
<literal>:<replaceable>number</replaceable>.<replaceable>number</replaceable></literal>).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--acquired</option></term>
<listitem><para>The opposite of <option>--unique</option> —
only "well-known" names will be shown.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--activatable</option></term>
<listitem><para>When showing the list of peers, show only
peers which have actually not been activated yet, but may be
started automatically if accessed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--match=<replaceable>MATCH</replaceable></option></term>
<listitem><para>When showing messages being exchanged, show only the
subset matching <replaceable>MATCH</replaceable>.
See
<citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--size=</option></term>
<listitem>
<para>When used with the <command>capture</command> command,
specifies the maximum bus message size to capture
("snaplen"). Defaults to 4096 bytes.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--list</option></term>
<listitem>
<para>When used with the <command>tree</command> command, shows a
flat list of object paths instead of a tree.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-q</option></term>
<term><option>--quiet</option></term>
<listitem>
<para>When used with the <command>call</command> command,
suppresses display of the response message payload. Note that even
if this option is specified, errors returned will still be
printed and the tool will indicate success or failure with
the process exit code.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--verbose</option></term>
<listitem>
<para>When used with the <command>call</command> or
<command>get-property</command> command, shows output in a
more verbose format.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--xml-interface</option></term>
<listitem>
<para>When used with the <command>introspect</command> call, dump the XML description received from
the D-Bus <constant>org.freedesktop.DBus.Introspectable.Introspect</constant> call instead of the
normal output.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--json=</option><replaceable>MODE</replaceable></term>
<listitem>
<para>When used with the <command>call</command> or <command>get-property</command> command, shows output
formatted as JSON. Expects one of <literal>short</literal> (for the shortest possible output without any
redundant whitespace or line breaks) or <literal>pretty</literal> (for a pretty version of the same, with
indentation and line breaks). Note that transformation from D-Bus marshalling to JSON is done in a loss-less
way, which means type information is embedded into the JSON object tree.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-j</option></term>
<listitem>
<para>Equivalent to <option>--json=pretty</option> when invoked interactively from a terminal. Otherwise
equivalent to <option>--json=short</option>, in particular when the output is piped to some other
program.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--expect-reply=</option><replaceable>BOOL</replaceable></term>
<listitem>
<para>When used with the <command>call</command> command,
specifies whether <command>busctl</command> shall wait for
completion of the method call, output the returned method
response data, and return success or failure via the process
exit code. If this is set to <literal>no</literal>, the
method call will be issued but no response is expected, the
tool terminates immediately, and thus no response can be
shown, and no success or failure is returned via the exit
code. To only suppress output of the reply message payload,
use <option>--quiet</option> above. Defaults to
<literal>yes</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--auto-start=</option><replaceable>BOOL</replaceable></term>
<listitem>
<para>When used with the <command>call</command> or <command>emit</command> command, specifies
whether the method call should implicitly activate the
called service, should it not be running yet but is
configured to be auto-started. Defaults to
<literal>yes</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--allow-interactive-authorization=</option><replaceable>BOOL</replaceable></term>
<listitem>
<para>When used with the <command>call</command> command,
specifies whether the services may enforce interactive
authorization while executing the operation, if the security
policy is configured for this. Defaults to
<literal>yes</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--timeout=</option><replaceable>SECS</replaceable></term>
<listitem>
<para>When used with the <command>call</command> command,
specifies the maximum time to wait for method call
completion. If no time unit is specified, assumes
seconds. The usual other units are understood, too (ms, us,
s, min, h, d, w, month, y). Note that this timeout does not
apply if <option>--expect-reply=no</option> is used, as the
tool does not wait for any reply message then. When not
specified or when set to 0, the default of
<literal>25s</literal> is assumed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--augment-creds=</option><replaceable>BOOL</replaceable></term>
<listitem>
<para>Controls whether credential data reported by
<command>list</command> or <command>status</command> shall
be augmented with data from
<filename>/proc/</filename>. When this is turned on, the data
shown is possibly inconsistent, as the data read from
<filename>/proc/</filename> might be more recent than the rest of
the credential information. Defaults to <literal>yes</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--watch-bind=</option><replaceable>BOOL</replaceable></term>
<listitem>
<para>Controls whether to wait for the specified <constant>AF_UNIX</constant> bus socket to appear in the
file system before connecting to it. Defaults to off. When enabled, the tool will watch the file system until
the socket is created and then connect to it.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--destination=</option><replaceable>SERVICE</replaceable></term>
<listitem>
<para>Takes a service name. When used with the <command>emit</command> command, a signal is
emitted to the specified service.</para>
</listitem>
</varlistentry>
<xi:include href="user-system-options.xml" xpointer="user" />
<xi:include href="user-system-options.xml" xpointer="system" />
<xi:include href="user-system-options.xml" xpointer="host" />
<xi:include href="user-system-options.xml" xpointer="machine" />
<varlistentry>
<term><option>-l</option></term>
<term><option>--full</option></term>
<listitem>
<para>Do not ellipsize the output in <command>list</command> command.</para>
</listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="no-pager" />
<xi:include href="standard-options.xml" xpointer="no-legend" />
<xi:include href="standard-options.xml" xpointer="help" />
<xi:include href="standard-options.xml" xpointer="version" />
</variablelist>
</refsect1>
<refsect1>
<title>Parameter Formatting</title>
<para>The <command>call</command> and
<command>set-property</command> commands take a signature string
followed by a list of parameters formatted as string (for details
on D-Bus signature strings, see the <ulink
url="http://dbus.freedesktop.org/doc/dbus-specification.html#type-system">Type
system chapter of the D-Bus specification</ulink>). For simple
types, each parameter following the signature should simply be the
parameter's value formatted as string. Positive boolean values may
be formatted as <literal>true</literal>, <literal>yes</literal>,
<literal>on</literal>, or <literal>1</literal>; negative boolean
values may be specified as <literal>false</literal>,
<literal>no</literal>, <literal>off</literal>, or
<literal>0</literal>. For arrays, a numeric argument for the
number of entries followed by the entries shall be specified. For
variants, the signature of the contents shall be specified,
followed by the contents. For dictionaries and structs, the
contents of them shall be directly specified.</para>
<para>For example,
<programlisting>s jawoll</programlisting> is the formatting
of a single string <literal>jawoll</literal>.</para>
<para>
<programlisting>as 3 hello world foobar</programlisting>
is the formatting of a string array with three entries,
<literal>hello</literal>, <literal>world</literal> and
<literal>foobar</literal>.</para>
<para>
<programlisting>a{sv} 3 One s Eins Two u 2 Yes b true</programlisting>
is the formatting of a dictionary
array that maps strings to variants, consisting of three
entries. The string <literal>One</literal> is assigned the
string <literal>Eins</literal>. The string
<literal>Two</literal> is assigned the 32-bit unsigned
integer 2. The string <literal>Yes</literal> is assigned a
positive boolean.</para>
<para>Note that the <command>call</command>,
<command>get-property</command>, <command>introspect</command>
commands will also generate output in this format for the returned
data. Since this format is sometimes too terse to be easily
understood, the <command>call</command> and
<command>get-property</command> commands may generate a more
verbose, multi-line output when passed the
<option>--verbose</option> option.</para>
</refsect1>
<refsect1>
<title>Examples</title>
<example>
<title>Write and Read a Property</title>
<para>The following two commands first write a property and then
read it back. The property is found on the
<literal>/org/freedesktop/systemd1</literal> object of the
<literal>org.freedesktop.systemd1</literal> service. The name of
the property is <literal>LogLevel</literal> on the
<literal>org.freedesktop.systemd1.Manager</literal>
interface. The property contains a single string:</para>
<programlisting># busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug
# busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel
s "debug"</programlisting>
</example>
<example>
<title>Terse and Verbose Output</title>
<para>The following two commands read a property that contains
an array of strings, and first show it in terse format, followed
by verbose format:</para>
<programlisting>$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
as 2 "LANG=en_US.UTF-8" "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
$ busctl get-property --verbose org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
ARRAY "s" {
STRING "LANG=en_US.UTF-8";
STRING "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin";
};</programlisting>
</example>
<example>
<title>Invoking a Method</title>
<para>The following command invokes the
<literal>StartUnit</literal> method on the
<literal>org.freedesktop.systemd1.Manager</literal>
interface of the
<literal>/org/freedesktop/systemd1</literal> object
of the <literal>org.freedesktop.systemd1</literal>
service, and passes it two strings
<literal>cups.service</literal> and
<literal>replace</literal>. As a result of the method
call, a single object path parameter is received and
shown:</para>
<programlisting># busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartUnit ss "cups.service" "replace"
o "/org/freedesktop/systemd1/job/42684"</programlisting>
</example>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry project='dbus'><refentrytitle>dbus-daemon</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<ulink url="https://www.freedesktop.org/wiki/Software/dbus">D-Bus</ulink>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry project='die-net'><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
|