/etc/config/, and the uci command-line tool and libuci library provide a consistent API for reading and modifying these files.
Architecture
| Component | Package | Description |
|---|---|---|
libuci | libuci | C library for reading/writing UCI config files |
uci | uci | Command-line utility |
libuci-lua | libuci-lua | Lua bindings for libuci |
/etc/config/. Each file represents a configuration domain (e.g., network, system, firewall, wireless).
UCI File Format
| Keyword | Syntax | Description |
|---|---|---|
config | config <type> [<name>] | Start a new section. <name> is optional (anonymous sections get auto-names like cfg123456). |
option | option <name> '<value>' | Set a single string value. |
list | list <name> '<value>' | Append a value to a list option. Multiple list lines with the same name create a list. |
Full CLI Reference
Reading Configuration
Writing Configuration
Batch Mode
Import
Transaction Model
UCI uses a staged commit model:uci set/uci add/uci deletewrite changes to a temporary overlay in/tmp/.uci/uci commitatomically writes the changes to/etc/config/uci revertdiscards the staged changes
commit and the relevant daemon is reloaded.
Practical Examples
Set the Hostname
Configure a Static LAN IP
Add a Firewall Rule
Read Config in a Shell Script
UCI Path Syntax
UCI addresses follow the format:| Path | Refers to |
|---|---|
network | Entire network config file |
network.lan | Section named lan in network |
network.lan.ipaddr | Option ipaddr inside section lan |
network.@interface[0] | First anonymous section of type interface |
network.@interface[-1] | Last anonymous section of type interface |