2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
7 xmlns:xi="http://www.w3.org/2001/XInclude">
11 <productname>systemd</productname>
15 <refentrytitle>busctl</refentrytitle>
16 <manvolnum>1</manvolnum>
20 <refname>busctl</refname>
21 <refpurpose>Introspect the bus</refpurpose>
26 <command>busctl</command>
27 <arg choice="opt" rep="repeat">OPTIONS</arg>
28 <arg choice="opt">COMMAND</arg>
29 <arg choice="opt" rep="repeat"><replaceable>NAME</replaceable></arg>
34 <title>Description</title>
36 <para><command>busctl</command> may be used to
37 introspect and monitor the D-Bus bus.</para>
41 <title>Commands</title>
43 <para>The following commands are understood:</para>
47 <term><command>list</command></term>
49 <listitem><para>Show all peers on the bus, by their service
50 names. By default, shows both unique and well-known names, but
51 this may be changed with the <option>--unique</option> and
52 <option>--acquired</option> switches. This is the default
53 operation if no command is specified.</para>
55 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
59 <term><command>status</command> <arg choice="opt"><replaceable>SERVICE</replaceable></arg></term>
61 <listitem><para>Show process information and credentials of a
62 bus service (if one is specified by its unique or well-known
63 name), a process (if one is specified by its numeric PID), or
64 the owner of the bus (if no parameter is
67 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
71 <term><command>monitor</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
73 <listitem><para>Dump messages being exchanged. If
74 <replaceable>SERVICE</replaceable> is specified, show messages
75 to or from this peer, identified by its well-known or unique
76 name. Otherwise, show all messages on the bus. Use
77 <keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo>
78 to terminate the dump.</para>
80 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
84 <term><command>capture</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
86 <listitem><para>Similar to <command>monitor</command> but
87 writes the output in pcapng format (for details, see
88 <ulink url="https://github.com/pcapng/pcapng/">
89 PCAP Next Generation (pcapng) Capture File Format</ulink>).
90 Make sure to redirect standard output to a file or pipe. Tools like
91 <citerefentry project='die-net'><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry>
92 may be used to dissect and view the resulting
95 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
99 <term><command>tree</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
101 <listitem><para>Shows an object tree of one or more
102 services. If <replaceable>SERVICE</replaceable> is specified,
103 show object tree of the specified services only. Otherwise,
104 show all object trees of all services on the bus that acquired
105 at least one well-known name.</para>
107 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
111 <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>
113 <listitem><para>Show interfaces, methods, properties and
114 signals of the specified object (identified by its path) on
115 the specified service. If the interface argument is passed, the
116 output is limited to members of the specified
119 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
123 <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>
125 <listitem><para>Invoke a method and show the response. Takes a
126 service name, object path, interface name and method name. If
127 parameters shall be passed to the method call, a signature
128 string is required, followed by the arguments, individually
129 formatted as strings. For details on the formatting used, see
130 below. To suppress output of the returned data, use the
131 <option>--quiet</option> option.</para>
133 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
137 <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>
139 <listitem><para>Emit a signal. Takes an object path, interface name and method name. If parameters
140 shall be passed, a signature string is required, followed by the arguments, individually formatted as
141 strings. For details on the formatting used, see below. To specify the destination of the signal,
142 use the <option>--destination=</option> option.</para>
144 <xi:include href="version-info.xml" xpointer="v242"/></listitem>
148 <term><command>wait</command> <arg choice="opt"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>SIGNAL</replaceable></arg></term>
150 <listitem><para>Wait for a signal. Takes an object path, interface name, and signal name. To suppress
151 output of the returned data, use the <option>--quiet</option> option. The service name may be
152 omitted, in which case busctl will match signals from any sender.</para>
154 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
158 <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>
160 <listitem><para>Retrieve the current value of one or more
161 object properties. Takes a service name, object path,
162 interface name and property name. Multiple properties may be
163 specified at once, in which case their values will be shown one
164 after the other, separated by newlines. The output is, by
165 default, in terse format. Use <option>--verbose</option> for a
166 more elaborate output format.</para>
168 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
172 <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>
174 <listitem><para>Set the current value of an object
175 property. Takes a service name, object path, interface name,
176 property name, property signature, followed by a list of
177 parameters formatted as strings.</para>
179 <xi:include href="version-info.xml" xpointer="v218"/></listitem>
183 <term><command>help</command></term>
185 <listitem><para>Show command syntax help.</para>
187 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
193 <title>Options</title>
195 <para>The following options are understood:</para>
199 <term><option>--address=<replaceable>ADDRESS</replaceable></option></term>
201 <listitem><para>Connect to the bus specified by
202 <replaceable>ADDRESS</replaceable> instead of using suitable
203 defaults for either the system or user bus (see
204 <option>--system</option> and <option>--user</option>
207 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
211 <term><option>--show-machine</option></term>
213 <listitem><para>When showing the list of peers, show a
214 column containing the names of containers they belong to.
216 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
219 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
223 <term><option>--unique</option></term>
225 <listitem><para>When showing the list of peers, show only
226 "unique" names (of the form
227 <literal>:<replaceable>number</replaceable>.<replaceable>number</replaceable></literal>).
230 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
234 <term><option>--acquired</option></term>
236 <listitem><para>The opposite of <option>--unique</option> —
237 only "well-known" names will be shown.</para>
239 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
243 <term><option>--activatable</option></term>
245 <listitem><para>When showing the list of peers, show only
246 peers which have actually not been activated yet, but may be
247 started automatically if accessed.</para>
249 <xi:include href="version-info.xml" xpointer="v209"/>
254 <term><option>--match=<replaceable>MATCH</replaceable></option></term>
256 <listitem><para>When showing messages being exchanged, show only the
257 subset matching <replaceable>MATCH</replaceable>.
259 <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
262 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
266 <term><option>--size=</option></term>
269 <para>When used with the <command>capture</command> command,
270 specifies the maximum bus message size to capture
271 ("snaplen"). Defaults to 4096 bytes.</para>
273 <xi:include href="version-info.xml" xpointer="v218"/>
278 <term><option>--list</option></term>
281 <para>When used with the <command>tree</command> command, shows a
282 flat list of object paths instead of a tree.</para>
284 <xi:include href="version-info.xml" xpointer="v218"/>
289 <term><option>-q</option></term>
290 <term><option>--quiet</option></term>
293 <para>When used with the <command>call</command> command,
294 suppresses display of the response message payload. Note that even
295 if this option is specified, errors returned will still be
296 printed and the tool will indicate success or failure with
297 the process exit code.</para>
299 <xi:include href="version-info.xml" xpointer="v218"/>
304 <term><option>--verbose</option></term>
307 <para>When used with the <command>call</command> or
308 <command>get-property</command> command, shows output in a
309 more verbose format.</para>
311 <xi:include href="version-info.xml" xpointer="v218"/>
316 <term><option>--xml-interface</option></term>
319 <para>When used with the <command>introspect</command> call, dump the XML description received from
320 the D-Bus <constant>org.freedesktop.DBus.Introspectable.Introspect</constant> call instead of the
321 normal output.</para>
323 <xi:include href="version-info.xml" xpointer="v243"/>
328 <term><option>--json=<replaceable>MODE</replaceable></option></term>
331 <para>When used with the <command>call</command> or <command>get-property</command> command, shows output
332 formatted as JSON. Expects one of <literal>short</literal> (for the shortest possible output without any
333 redundant whitespace or line breaks) or <literal>pretty</literal> (for a pretty version of the same, with
334 indentation and line breaks). Note that transformation from D-Bus marshalling to JSON is done in a loss-less
335 way, which means type information is embedded into the JSON object tree.</para>
337 <xi:include href="version-info.xml" xpointer="v240"/>
342 <term><option>-j</option></term>
345 <para>Equivalent to <option>--json=pretty</option> when invoked interactively from a terminal. Otherwise
346 equivalent to <option>--json=short</option>, in particular when the output is piped to some other
349 <xi:include href="version-info.xml" xpointer="v240"/>
354 <term><option>--expect-reply=<replaceable>BOOL</replaceable></option></term>
357 <para>When used with the <command>call</command> command,
358 specifies whether <command>busctl</command> shall wait for
359 completion of the method call, output the returned method
360 response data, and return success or failure via the process
361 exit code. If this is set to <literal>no</literal>, the
362 method call will be issued but no response is expected, the
363 tool terminates immediately, and thus no response can be
364 shown, and no success or failure is returned via the exit
365 code. To only suppress output of the reply message payload,
366 use <option>--quiet</option> above. Defaults to
367 <literal>yes</literal>.</para>
369 <xi:include href="version-info.xml" xpointer="v218"/>
374 <term><option>--auto-start=<replaceable>BOOL</replaceable></option></term>
377 <para>When used with the <command>call</command> or <command>emit</command> command, specifies
378 whether the method call should implicitly activate the
379 called service, should it not be running yet but is
380 configured to be auto-started. Defaults to
381 <literal>yes</literal>.</para>
383 <xi:include href="version-info.xml" xpointer="v218"/>
388 <term><option>--allow-interactive-authorization=<replaceable>BOOL</replaceable></option></term>
391 <para>When used with the <command>call</command> command,
392 specifies whether the services may enforce interactive
393 authorization while executing the operation, if the security
394 policy is configured for this. Defaults to
395 <literal>yes</literal>.</para>
397 <xi:include href="version-info.xml" xpointer="v218"/>
402 <term><option>--timeout=<replaceable>SECS</replaceable></option></term>
405 <para>When used with the <command>call</command> command, specifies the maximum time to wait for
406 method call completion. When used with the <command>monitor</command> command, since version v257,
407 specifies the maximum time to wait for messages before automatically exiting. If no time unit is
408 specified, assumes seconds. The usual other units are understood, too (ms, us, s, min, h, d, w,
409 month, y). Note that this timeout does not apply if <option>--expect-reply=no</option> is used,
410 when combined with the <command>call</command> command, as the tool does not wait for any reply
411 message then. When not specified or when set to 0, the default of <literal>25s</literal> is
412 assumed for the <command>call</command> command, and it is disabled for the
413 <command>monitor</command> command.</para>
415 <xi:include href="version-info.xml" xpointer="v218"/>
420 <term><option>--limit-messages=<replaceable>NUMBER</replaceable></option></term>
421 <term><option>-N <replaceable>NUMBER</replaceable></option></term>
424 <para>When used with the <command>monitor</command> command, if enabled will make
425 <command>busctl</command> exit when the specified number of messages have been received and
426 printed. This is useful in combination with <option>--match=</option>, to wait for the specified
427 number of occurrences of specific D-Bus messages.</para>
429 <xi:include href="version-info.xml" xpointer="v257"/>
434 <term><option>--augment-creds=<replaceable>BOOL</replaceable></option></term>
437 <para>Controls whether credential data reported by
438 <command>list</command> or <command>status</command> shall
439 be augmented with data from
440 <filename>/proc/</filename>. When this is turned on, the data
441 shown is possibly inconsistent, as the data read from
442 <filename>/proc/</filename> might be more recent than the rest of
443 the credential information. Defaults to <literal>yes</literal>.</para>
445 <xi:include href="version-info.xml" xpointer="v218"/>
450 <term><option>--watch-bind=<replaceable>BOOL</replaceable></option></term>
453 <para>Controls whether to wait for the specified <constant>AF_UNIX</constant> bus socket to appear in the
454 file system before connecting to it. Defaults to off. When enabled, the tool will watch the file system until
455 the socket is created and then connect to it.</para>
457 <xi:include href="version-info.xml" xpointer="v237"/>
462 <term><option>--destination=<replaceable>SERVICE</replaceable></option></term>
465 <para>Takes a service name. When used with the <command>emit</command> command, a signal is
466 emitted to the specified service.</para>
468 <xi:include href="version-info.xml" xpointer="v242"/>
472 <xi:include href="user-system-options.xml" xpointer="user" />
473 <xi:include href="user-system-options.xml" xpointer="system" />
474 <xi:include href="user-system-options.xml" xpointer="host" />
475 <xi:include href="user-system-options.xml" xpointer="machine" />
476 <xi:include href="user-system-options.xml" xpointer="capsule" />
479 <term><option>-l</option></term>
480 <term><option>--full</option></term>
483 <para>Do not ellipsize the output in <command>list</command> command.</para>
485 <xi:include href="version-info.xml" xpointer="v245"/>
489 <xi:include href="standard-options.xml" xpointer="no-pager" />
490 <xi:include href="standard-options.xml" xpointer="no-legend" />
491 <xi:include href="standard-options.xml" xpointer="help" />
492 <xi:include href="standard-options.xml" xpointer="version" />
497 <title>Parameter Formatting</title>
499 <para>The <command>call</command> and
500 <command>set-property</command> commands take a signature string
501 followed by a list of parameters formatted as string (for details
502 on D-Bus signature strings, see the <ulink
503 url="https://dbus.freedesktop.org/doc/dbus-specification.html#type-system">Type
504 system chapter of the D-Bus specification</ulink>). For simple
505 types, each parameter following the signature should simply be the
506 parameter's value formatted as string. Positive boolean values may
507 be formatted as <literal>true</literal>, <literal>yes</literal>,
508 <literal>on</literal>, or <literal>1</literal>; negative boolean
509 values may be specified as <literal>false</literal>,
510 <literal>no</literal>, <literal>off</literal>, or
511 <literal>0</literal>. For arrays, a numeric argument for the
512 number of entries followed by the entries shall be specified. For
513 variants, the signature of the contents shall be specified,
514 followed by the contents. For dictionaries and structs, the
515 contents of them shall be directly specified.</para>
518 <programlisting>s jawoll</programlisting> is the formatting
519 of a single string <literal>jawoll</literal>.</para>
522 <programlisting>as 3 hello world foobar</programlisting>
523 is the formatting of a string array with three entries,
524 <literal>hello</literal>, <literal>world</literal> and
525 <literal>foobar</literal>.</para>
528 <programlisting>a{sv} 3 One s Eins Two u 2 Yes b true</programlisting>
529 is the formatting of a dictionary
530 array that maps strings to variants, consisting of three
531 entries. The string <literal>One</literal> is assigned the
532 string <literal>Eins</literal>. The string
533 <literal>Two</literal> is assigned the 32-bit unsigned
534 integer 2. The string <literal>Yes</literal> is assigned a
535 positive boolean.</para>
537 <para>Note that the <command>call</command>,
538 <command>get-property</command>, <command>introspect</command>
539 commands will also generate output in this format for the returned
540 data. Since this format is sometimes too terse to be easily
541 understood, the <command>call</command> and
542 <command>get-property</command> commands may generate a more
543 verbose, multi-line output when passed the
544 <option>--verbose</option> option.</para>
548 <title>Examples</title>
551 <title>Write and Read a Property</title>
553 <para>The following two commands first write a property and then
554 read it back. The property is found on the
555 <literal>/org/freedesktop/systemd1</literal> object of the
556 <literal>org.freedesktop.systemd1</literal> service. The name of
557 the property is <literal>LogLevel</literal> on the
558 <literal>org.freedesktop.systemd1.Manager</literal>
559 interface. The property contains a single string:</para>
561 <programlisting># busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug
562 # busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel
563 s "debug"</programlisting>
568 <title>Terse and Verbose Output</title>
570 <para>The following two commands read a property that contains
571 an array of strings, and first show it in terse format, followed
572 by verbose format:</para>
574 <programlisting>$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
575 as 2 "LANG=en_US.UTF-8" "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
576 $ busctl get-property --verbose org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
578 STRING "LANG=en_US.UTF-8";
579 STRING "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin";
584 <title>Invoking a Method</title>
586 <para>The following command invokes the
587 <literal>StartUnit</literal> method on the
588 <literal>org.freedesktop.systemd1.Manager</literal>
590 <literal>/org/freedesktop/systemd1</literal> object
591 of the <literal>org.freedesktop.systemd1</literal>
592 service, and passes it two strings
593 <literal>cups.service</literal> and
594 <literal>replace</literal>. As a result of the method
595 call, a single object path parameter is received and
598 <programlisting># busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartUnit ss "cups.service" "replace"
599 o "/org/freedesktop/systemd1/job/42684"</programlisting>
604 <title>See Also</title>
606 <para><simplelist type="inline">
607 <member><citerefentry project='dbus'><refentrytitle>dbus-daemon</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
608 <member><ulink url="https://www.freedesktop.org/wiki/Software/dbus">D-Bus</ulink></member>
609 <member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
610 <member><citerefentry><refentrytitle>varlinkctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
611 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
612 <member><citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
613 <member><citerefentry project='die-net'><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>