ubus
Communicate between processes over the uBus
TLDR
List available objects
Retrieve system information in JSON format
Listen to events
Display help
SYNOPSIS
ubus [
PARAMETERS
-s <socket>
Specifies the path to the ubus socket file, defaulting to /var/run/ubus.sock.
-t <timeout>
Sets the timeout in milliseconds for ubus calls.
-v
Enables verbose output, providing more detailed information about operations.
-m
Monitors raw ubus messages, useful for low-level debugging of the bus traffic.
-S
Outputs JSON in a simple, non-prettified format (single line) rather than a human-readable one.
-l
Lists ubus objects and their methods in a tree-like, hierarchical format.
DESCRIPTION
ubus is the user-space message bus system developed specifically for OpenWrt, an embedded Linux distribution. It provides a lightweight and efficient mechanism for inter-process communication (IPC) between various system services and applications running on embedded devices. Unlike heavier IPC systems like D-Bus, ubus is designed with minimal resource consumption in mind, making it ideal for devices with limited memory and processing power. It allows programs to register objects with methods, which other programs can then call. It also supports event broadcasting, enabling applications to subscribe to and react to system events. This centralized communication enables modularity and simplifies system management in OpenWrt environments.
CAVEATS
ubus is primarily used in OpenWrt and is not a standard component of general-purpose Linux distributions. It requires the ubusd daemon to be running for its operations. The specific API (objects and methods) exposed via ubus can vary significantly between different OpenWrt versions, and internal methods may not have guaranteed stability. Error messages can sometimes be terse or cryptic, requiring deeper understanding of the underlying OpenWrt system.
COMMON SUBCOMMANDS
The ubus utility operates primarily through various subcommands, each performing a specific action on the message bus:
call <object> <method> [<json-string>]: Invokes a specific method on a registered ubus object. This is the primary way to interact with OpenWrt services, often passing JSON data as arguments.
listen [<event> ...]: Subscribes to and displays ubus events as they occur. It's invaluable for real-time monitoring and debugging system changes.
send <event> <json-string>: Publishes a custom event to the ubus, optionally including JSON data. Useful for inter-application communication and custom scripting.
monitor: Provides a low-level, continuous view of all ubus traffic, including method calls, return values, and broadcasted events. Essential for deep debugging of bus interactions.
list [<object>]: Lists all available ubus objects and their exposed methods. Specifying an <object> filters the list to show methods for that specific object. This command helps in discovering available APIs.
wait_for <object> [<object> ...]: Blocks execution until one or more specified ubus objects become available on the bus. This is particularly useful in startup scripts to ensure dependencies are met before proceeding.
HISTORY
ubus was developed as a core component of OpenWrt, designed to provide a lightweight and efficient inter-process communication mechanism tailored for resource-constrained embedded devices, specifically to address the perceived overhead of D-Bus in such environments. It became central to OpenWrt's system architecture, allowing various daemons (such as netifd for network configuration, rpcd for RPC calls, and hostapd for Wi-Fi management) to communicate and expose their functionalities in a standardized way. Its development closely tracks OpenWrt's evolution, becoming an indispensable and stable part of the OpenWrt ecosystem since its introduction.
SEE ALSO
dbus-send(1), dbus-monitor(1), ipc(7)