LinuxCommandLibrary

busctl

Introspect and control the D-Bus message bus

TLDR

Show all peers on the bus, by their service names

$ busctl list
copy

Show process information and credentials of a bus service, a process, or the owner of the bus (if no parameter is specified)
$ busctl status [service|pid]
copy

Dump messages being exchanged. If no service is specified, show all messages on the bus
$ busctl monitor [service1 service2 ...]
copy

Show an object tree of one or more services (or all services if no service is specified)
$ busctl tree [service1 service2 ...]
copy

Show interfaces, methods, properties and signals of the specified object on the specified service
$ busctl introspect [service] [path/to/object]
copy

Retrieve the current value of one or more object properties
$ busctl get-property [service] [path/to/object] [interface_name] [property_name]
copy

Invoke a method and show the response
$ busctl call [service] [path/to/object] [interface_name] [method_name]
copy

SYNOPSIS

busctl [OPTIONS...] COMMAND [ARGUMENTS...]

Common Commands:
busctl list [SERVICE]
busctl status [SERVICE]
busctl monitor [MATCH...]
busctl call SERVICE PATH INTERFACE METHOD [SIGNATURE [ARGUMENTS...]]
busctl get-property SERVICE PATH INTERFACE PROPERTY
busctl set-property SERVICE PATH INTERFACE PROPERTY SIGNATURE ARGUMENT
busctl introspect SERVICE PATH
busctl tree [SERVICE]

PARAMETERS

--json
    Format output as JSON for machine parsing.

--no-pager
    Do not pipe output into a pager.

--no-legend
    Do not print the column legend or header lines.

--user
    Talk to the user's session D-Bus bus instead of the system bus.

--system
    Talk to the system D-Bus bus (this is the default).

--address=ADDRESS
    Connect to the specified D-Bus address instead of the default system or user bus.

--show-machine
    Show the machine name as the first column of the output, useful for `systemd-machined` integration.

list
    List names of D-Bus services and their process IDs (PIDs).

status SERVICE
    Show runtime status information about a D-Bus service, including its PID and associated unit.

monitor [MATCH...]
    Monitor D-Bus messages (method calls, replies, signals) matching optional rules.

call SERVICE PATH INTERFACE METHOD [SIGNATURE [ARGUMENTS...]]
    Invoke a method on a D-Bus object with specified arguments and types.

get-property SERVICE PATH INTERFACE PROPERTY
    Retrieve a property from a D-Bus object.

set-property SERVICE PATH INTERFACE PROPERTY SIGNATURE ARGUMENT
    Set a property on a D-Bus object with a specified value and type.

introspect SERVICE PATH
    Show available interfaces, methods, signals, and properties for a D-Bus object.

tree [SERVICE]
    Show a tree of available D-Bus objects for a specific service or all services.

cap-set SERVICE CAPABILITY
    Set a specific D-Bus capability for a service (typically for advanced use or debugging).

DESCRIPTION

busctl is a command-line utility used for introspecting, calling, and monitoring D-Bus. It is part of the systemd suite of tools and provides a powerful interface to interact with D-Bus services and objects. D-Bus is an inter-process communication (IPC) mechanism primarily used in Linux for communication between applications, particularly system services and desktop environments.

With busctl, users can:

  • List active D-Bus services and their details.
  • Make method calls on D-Bus objects, including specifying arguments and types.
  • Get and set properties of D-Bus objects.
  • Monitor D-Bus traffic, including method calls, replies, and signals.
  • Introspect D-Bus objects to discover available interfaces, methods, signals, and properties.
It simplifies D-Bus interaction, offering a more user-friendly interface compared to lower-level D-Bus tools or direct API usage, making it indispensable for system administrators and developers debugging D-Bus-related issues or exploring system functionality.

CAVEATS

busctl requires a basic understanding of D-Bus concepts (bus names, object paths, interfaces, methods, signals, properties, signatures) to be used effectively.

Invoking methods or setting properties on system services can have significant system-wide effects and may require elevated privileges (e.g., `sudo`). Always exercise caution when making changes.

D-Bus object paths and interface names are case-sensitive. Typographical errors can lead to 'No such object' or 'No such interface' errors.

The --json output format is primarily intended for machine parsing and may not be as human-readable as the default output.

D-BUS DATA TYPES AND SIGNATURES

D-Bus messages, arguments, and return values are strongly typed. busctl uses D-Bus signatures to specify argument types for method calls and property assignments. A signature is a string representing a sequence of types, e.g., 's' for string, 'i' for 32-bit integer, 'b' for boolean, 'd' for double, 'v' for variant, 'a(ss)' for an array of structs containing two strings. Understanding these signatures is crucial for correctly crafting busctl call and busctl set-property commands.

For complex types like arrays or structs, busctl expects arguments to be provided in a specific, space-separated format. For example, to pass an array of strings, you might use 'as' 2 'string1' 'string2', where 'as' is the signature, '2' is the count, followed by the elements. A dictionary (array of key-value pairs) might be 'a{sv}' 2 'Key1' 'Value1' 'Key2' 'Value2'.

HISTORY

busctl was introduced as part of the systemd project, specifically with systemd version 217 (released in late 2014). Its development is closely tied to systemd's increasing reliance on D-Bus for inter-process communication and system management. It provides a native systemd tool for D-Bus interaction, complementing other systemd utilities like systemctl that also extensively use D-Bus. Its inclusion streamlined D-Bus introspection, debugging, and direct interaction within the systemd ecosystem, offering a more integrated and user-friendly experience compared to prior standalone D-Bus utilities.

SEE ALSO

dbus-daemon(1), systemctl(1), sd_bus_get_property(3), dbus(7)

Copied to clipboard