busctl command examples

busctl command examples

busctl – Introspect the bus

Example 1. Write and Read a Property

The following two commands first write a property and then read it back. The property is found on the “/org/freedesktop/systemd1” object of the “org.freedesktop.systemd1” service. The name of the property is “LogLevel” on the “org.freedesktop.systemd1.Manager” interface. The property contains a single string:

# 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”

Example 2. Terse and Verbose Output

The following two commands read a property that contains an array of strings, and first show it in terse format, followed by verbose format:

$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd

1.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 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin";

Example 3. Invoking a Method

The following command invokes a the “StartUnit” method on the “org.freedesktop.systemd1.Manager” interface of the “/org/freedesktop/systemd1” object of the “org.freedesktop.systemd1” service, and passes it two strings “cups.service” and “replace”. As result of the method call a single object path parameter is received and shown:

# busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartUnit ss “cups.service” “replace”

o “/org/freedesktop/systemd1/job/42684”


Leave a Reply

Your email address will not be published. Required fields are marked *