# Introduction to UCI

Last edited by greenbreakfast, 2016-04-22 20:17:00

Short for Unified Configuration Interface, uci is OpenWRT centralized configuration interface.

To modify congifuration files we can either navigate to the specific file usually located in the "/etc/config" folder. Alternatively, you can use the uci command line to utility to achieve the same thing. Uci is particular handy when it comes to making modifcations to config files from within a shell script without changing any other parts of the file. For further reading, consult OpenWRT's documentation on the subject which can be found here.

In keeping with our prior tutorials, let's learn about uci through an example. In this tutorial we will secure the Omega's access point with a password.

### Example

To call the uci, from the command line simply type:

uci

The result will give you all the options you can call for uci.

Next lets take a closer look at our wireless configuration file, this is the same one that is in our '/etc/config/' folder, but we want to exploit the convenience of using uci. So enter:

uci export wireless

Or alternatively you can use the uci show command, which will prove useful shortly.

uci show wireless

Now in order for us to secure our wifi access point we must change our encryption and add a key. We wil have to use the following command:

uci set <config>.<section>[.<option>]=<value>

Your probably wondering what the second part of the command means. I won't bore you with the details, if your interested refer to OpenWRT documentation, but the second part points to the exact line in the config file we would like to change and sets the new value. So in our case we would like to change our encryption from none to psk2. To determine the exact syntax for the second part refer to output of uci show wireless.

Now enter the following into your command line.

uci set wireless.@wifi-iface[0].encryption=psk2 

followed by this, to commit changes:

uci commit wireless
To observe the changes, re-enter the uci show wireless

You should similar changes as in the image below.

Now let's set our password for our key access point. Similar to our previous step we will enter the following command.

uci set wireless.@wifi-iface[0].key=password 

followed by

uci commit wireless
and to check our changes:
uci show wireless

Now to reset your Omega's wifi settings, enter:

/etc/init.d/boot reload

This will reload your configuration files. You will also need to restart your wifi service. To do that enter this into your command line.
wifi
Give it a few seconds and your Omega should broadcast a secured wifi signal. To check, open your network page and check avaiable networks, you should your Omega's wifi and it should require the password, which we set as "password" to login.

And voila, you have just used uci to secure your Omega access point.