LinuxCommandLibrary

uci

Manage system configuration settings

TLDR

Fetch a value

$ uci get [network.lan.ipaddr]
copy

List all options and their values
$ uci show [network]
copy

Set a value
$ uci set [config].[section].[option]=[value]
copy

Add a new section
$ uci add [config] [section]
copy

Delete a section or value
$ uci delete [config].[section].[option]
copy

Commit changes
$ uci commit [config]
copy

Discard uncommitted changes
$ uci revert [config]
copy

Display help
$ uci
copy

SYNOPSIS

uci command [options] [arguments]

PARAMETERS

add config section
    Adds a new section of type section to configuration config and prints the name of the new section to standard output.

changes [config]
    Lists all pending changes.

commit [config]
    Commits pending changes to persistent storage.

delete config.section[.option]
    Deletes the specified section or option.

export [config]
    Prints a dump of the specified configuration to standard output.

force
    Force overwrite option when setting values.

get config.section.option
    Retrieves the value of the specified option.

import config
    Imports a configuration from standard input.

revert config[.section[.option]]
    Reverts changes to the specified section or option.

rename config.section=new_section
    Renames a section.

set config.section.option=value
    Sets the value of the specified option.

show [config]
    Shows the contents of the specified configuration file.

source [file]
    Sources UCI configuration from file.

DESCRIPTION

The uci command provides a unified command-line interface for accessing and manipulating the system configuration files used by OpenWrt and other embedded Linux distributions. It abstracts away the underlying file format, typically represented as plain text configuration files organized in sections and options. uci allows you to read, write, and delete configuration values, making it easy to manage network settings, system services, and other configuration parameters. It uses a hierarchical namespace system to organize configuration data, enabling easy access to specific settings.

uci simplifies configuration management, allowing administrators to automate configuration changes using shell scripts and other tools. By using uci, users can avoid manually editing configuration files, reducing the risk of errors and improving system maintainability. The uci command handles parsing and formatting of the configuration data, ensuring data consistency and validity. It is a crucial tool for managing embedded Linux systems.

CAVEATS

uci is specific to systems that use UCI for configuration management, most notably OpenWrt. It may not be available or relevant on other Linux distributions.

CONFIGURATION FILE STRUCTURE

UCI configuration files are typically stored in the /etc/config/ directory. Each file represents a configuration domain (e.g., network, system). The files are structured into sections, which contain options and values.

UCI DEFAULTS

UCI defaults are used to initialize the system configuration. They are typically located in /etc/uci-defaults and are executed during the first boot process. They should be deleted after execution.

HISTORY

UCI was developed as part of the OpenWrt project to provide a consistent and manageable way to configure the system. It replaced earlier, less structured configuration approaches. Over time, it has become a core component of OpenWrt and has been adopted by other embedded systems.

SEE ALSO

ubus(1), uci-defaults(7)

Copied to clipboard