天天看點

Openwrt的uci操作

uci操作指令參數如下:

Openwrt的uci操作
Openwrt的uci操作

指令1:uci batch  說明:進入uci指令操作模式,與在終端操作的差別是,操作不需要加uci字首。該模式下,隻能識别uci指令; 如下面的:changes system

Openwrt的uci操作
Openwrt的uci操作

指令2:uci export [配置檔案的名稱] 說明:預設時,顯示所有uci能讀取的配置檔案的資訊,檢視的資訊包括修改過但為儲存的資訊; 例如:檢視network配置檔案的資訊:uci export network

Openwrt的uci操作
Openwrt的uci操作

指令3:uci import <配置檔案名> 說明:添加uci配置檔案,預設時,能進入配置狀态,但鍵入資料會報錯; 例:添加配置檔案hello_yang(檔案儲存的路徑:/etc/config/);      終端鍵入:uci import hello_yang 進入hello_yang檔案的操作模式;      鍵入下圖内容,ctrl+d鍵退出;

Openwrt的uci操作
Openwrt的uci操作

指令4:uci changes [<配置檔案名>] 說明:預設時,檢視所有uci修改過的資訊; 例:檢視配置檔案system的修改資訊:指令uci changes system

Openwrt的uci操作
Openwrt的uci操作

指令5:uci commit [<配置檔案名>]  說明:預設時,送出所有修改的uci資訊; 例:uci commit system就隻是送出配置檔案system的修改資訊

Openwrt的uci操作
Openwrt的uci操作

指令6:uci add 配置檔案名 配置項的類型 說明:這個指令格式限定了,沒有預設,操作該指令後,在相應的配置檔案中會添加配置項,傳回值為配置項名稱; 例:在配置檔案hello_yang中加配置項people_info,操作如下,終端鍵入:uci add hello_yang people_info,傳回      cfg04ae55(這個值就是help的section值);

Openwrt的uci操作

指令7:uci add_list <config>.<section>.<option>=<string> 說明:在配置檔案的配置項添加list項; 例:在配置檔案hello_yang的配置項people_info中添加home資訊

Openwrt的uci操作
Openwrt的uci操作

指令8:uci del_list <config>.<section>.<option>=<string> 說明:格式固定,string值要與配置檔案的string相同,否則操作無效。但不報錯; 例:如下所示

Openwrt的uci操作
Openwrt的uci操作

指令9:uci show [<config>.[<section>].[<option>]] 說明:檢視配置檔案的資訊,預設時,檢視所有配置的資訊; 例:下面一個檢視配置檔案的資訊,一個檢視配置檔案的配置項對應的資訊

Openwrt的uci操作
Openwrt的uci操作

指令10:uci get <config>.<section>[.<option>] 說明:擷取配置檔案的對應部分的内容; 例:擷取section的資訊,傳回為section_type,擷取option的資訊,傳回為配置的值;

Openwrt的uci操作
Openwrt的uci操作

指令11:uci set <config>.<section>[.<option>]=<value> 說明:修改配置檔案的配置資訊(config和option的資訊); 例:修改config的資訊,指令:uci set [email protected]_yang[0]="hello",修改為config對應的資訊;      修改option的資訊,指令:uci set [email protected]_yang[0].name="xiaoyang",修改為對應option的資訊;

Openwrt的uci操作
Openwrt的uci操作

指令12:uci delete <config>.<section>[[.<option>][=<id>]] 說明:删除配置檔案的配置資訊。 例:如下,删除config和删除option

Openwrt的uci操作

指令13:uci rename <config>.<section>[.option]=<string> 說明:修改配置檔案的屬性資訊; 例:為沒有名字的config項添加名字,修改option的資訊;

Openwrt的uci操作
Openwrt的uci操作

指令14:revert <config>[.section][.option] 說明:它能回複檔案的修改資訊,但這個操作是相對于commit之後的,在沒有送出前,這個操作不起作用。 例:修改檔案的option資訊後,使用uci revert hello_yang恢複。

Openwrt的uci操作
Openwrt的uci操作

指令15:uci reorder <config>.<section>=<position> 說明:修改配置項config在檔案中的位置;優先級0最大,數字越大越排後。 例:

Openwrt的uci操作
Openwrt的uci操作