• 產品與解決方案
  • 行業解決方案
  • 服務
  • 支持
  • 合作夥伴
  • 關於我們

01-基礎配置命令參考

目錄

01-CLI命令

本章節下載 01-CLI命令  (268.18 KB)

01-CLI命令


1 CLI

1.1  CLI命令

1.1.1  alias

alias命令用來為命令或命令字符串配置別名。

undo alias命令用來取消相應配置。

【命令】

alias alias command

undo alias alias

【缺省情況】

係統為部分常用命令定義了缺省別名,如表1-1所示。

表1-1 係統定義的缺省別名

缺省別名

命令

access-list

acl

end

return

erase

delete

exit

quit

hostname

sysname

logging

info-center

no

undo

show

display

write

save

 

【視圖】

係統視圖

【缺省用戶角色】

network-admin

context-admin

【參數】

alias:表示命令的別名,為1~20個字符的字符串,區分大小寫。別名不能為“alias”,也不能包含空格。

command:表示配置別名的命令,可以為任意字符串。請用戶保證該命令字符串能夠被設備識別並執行,否則執行別名命令時將會失敗。

【使用指導】

係統定義的缺省別名無法取消。

通過本命令用戶可以為命令行指定一個或多個別名,也可以為命令行開頭的一個或多個關鍵字配置多個別名,使其符合用戶的使用習慣。

本命令可以為某條命令行配置別名,當執行該命令時可以直接使用別名以簡化輸入。例如將命令display ip routing-table的別名配置為shiprt,當需要使用display ip routing-table查看設備生效的配置時,直接輸入shiprt即可。

本命令可以為命令行起始的一個或多個關鍵字配置別名,使其更符合用戶習慣。所有使用該關鍵字開頭的命令行都可以使用別名命令來執行。例如,為display ip命令定義的別名為ship,在使用所有以display ip關鍵字開頭的命令行時,都可以使用ship進行配置。例如:

·     輸入ship routing-table可以執行命令display ip routing-table

·     輸入ship interface可以執行命令display ip interface

配置別名時,可以使用$n表示命令行中的參數或者關鍵字,這樣既可以用別名替代部分關鍵字來簡化輸入,又可以根據實際需要指定不同的參數或者關鍵字,增加了靈活性。$n最多可以使用9次,n為1~9的整數,表示參數或關鍵字出現的順序。比如,將命令display ip $1 | include $2的別名配置為shinc後,如果需要執行display ip routing-table | include Static命令來篩選並查看路由表中的所有靜態路由信息,可直接執行shinc routing-table Static;同樣如果需要執行display ip interface | include GigabitEthernet1/0/1,則可直接執行shinc interface GigabitEthernet1/0/1。

【舉例】

# 配置命令display ip routing-table的別名為shiprt

<Sysname> system-view

[Sysname] alias shiprt display ip routing-table

[Sysname] shiprt

Destinations : 13        Routes : 13

Destination/Mask   Proto   Pre Cost        NextHop         Interface

0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0

3.3.3.3/32         Static  60  0           192.168.1.62    GE1/0/1

127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0

127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0

127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0

127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

169.254.0.0/24     Direct  0   0           169.254.0.188   GE1/0/1

169.254.0.0/32     Direct  0   0           169.254.0.188   GE1/0/1

169.254.0.188/32   Direct  0   0           127.0.0.1       InLoop0

169.254.0.255/32   Direct  0   0           169.254.0.188   GE1/0/1

224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0

224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0

255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0

# 配置命令display ip $1 | include $2的別名為shinc,同時使用別名命令篩選並查看路由表中的所有靜態路由信息。

[Sysname] alias shinc display ip $1 | include $2

[Sysname] shinc routing-table Static

3.3.3.3/32         Static  60  0           192.168.1.62     GE1/0/1

【相關命令】

·     display alias

1.1.2  display | { begin | exclude | include }

display | { begin | exclude | include }命令用來使用正則表達式對顯示信息進行過濾。

【命令】

display command | [ count | { begin | exclude | include } regular-expression ] &<1-128>

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【參數】

command:命令關鍵字,取值可以通過輸入?來獲得。

begin:從包含正則表達式的行開始顯示。

exclude:隻顯示不包含正則表達式的行。

include:隻顯示包含正則表達式的行。

regular-expression:表示正則表達式,為1~256個字符的字符串,區分大小寫。

count:顯示上一層過濾後的顯示信息的行數。

&<1-128>:可以進行多層過濾。

【使用指導】

display命令查看顯示信息時,用戶可以使用正則表達式來過濾顯示信息,以便快速的找到自己關注的信息。關於正則表達式的詳細描述請參考“基礎配置指導”中的“CLI”。

【舉例】

# 查看包含VLAN的配置。

<Sysname> display current-configuration | include vlan

vlan 1

vlan 999

 port access vlan 999

# 統計包含alias的配置的函數。

<Sysname> display current-configuration | include alias | count

 Total lines: 1.

# 查看包含interface和TM的配置。

<Sysname>display  current-configuration | include interface | include TM

interface ATM2/0/17

interface ATM2/0/18

interface ATM2/0/19

interface ATM2/0/20

# 查看包含“interface ATM”的配置。

<Sysname>display  current-configuration | include interface ATM

interface ATM2/0/17

interface ATM2/0/18

interface ATM2/0/19

interface ATM2/0/20

1.1.3  display | by-linenum

display | by-linenum命令用來查看帶行號的顯示信息。

【命令】

display command | by-linenum

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【參數】

command:命令關鍵字,取值可以通過輸入?來獲得。

【使用指導】

使用本命令時,係統在顯示信息的同時會自動在每行顯示信息的前麵添加行號,以便當顯示信息較多時,能夠迅速定位到某行信息。

行號占5個字符,通常行號後麵接“:”。當by-linenumbegin參數一起使用時,行號後麵還可能接“-”,其中“:”表示該行符合匹配規則,“-”表示該行不符合匹配規則。

【舉例】

# 顯示VLAN 999信息的同時顯示行號。

<Sysname> display vlan 999 | by-linenum

    1:  VLAN ID: 999

    2:  VLAN type: Static

    3:  Route interface: Configured

    4:  IPv4 address: 192.168.2.1

    5:  IPv4 subnet mask: 255.255.255.0

    6:  Description: For LAN Access

    7:  Name: VLAN 0999

    8:  Tagged ports:   None

    9:  Untagged ports:

   10:     GigabitEthernet1/0/1

   11:

# 查看當前配置,從包含“user-group”字符串的行開始到最後一行配置信息,並同時顯示行號。(行號後為“:”表示該行包含“user-group”字符串,行號後為“-”表示該行不包含“user-group”字符串。)

<Sysname> display current-configuration | by-linenum begin user-group

  114:  user-group system

  115-  #

  116-  return

1.1.4  display >

display >命令用來將顯示信息獨立保存到文件。

【命令】

display command > filename

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【參數】

command:命令關鍵字,取值可以通過輸入?來獲得。

filename:文件名稱,為1~63個字符的字符串。

【使用指導】

display命令顯示的內容通常是統計信息、功能是否使能以及功能的相關參數配置,這些信息在設備運行過程中會隨著時間或者用戶的配置而改變。使用本命令可以將當前顯示信息保存到文件,可供用戶隨時比對和查看。

執行本命令時,如果filename不存在,係統會先創建該文件,再保存;如果filename已存在,則會覆蓋原文件的內容。

【舉例】

# 將display vlan 1的顯示信息保存到文件vlan.txt。

<Sysname> display vlan 1 > vlan.txt

查看vlan.txt的內容,驗證display >命令的執行效果。

<Sysname> more vlan.txt

VLAN ID: 1

 VLAN type: Static

 Route interface: Not configured

 Description: VLAN 0001

 Name: VLAN 0001

 Tagged ports:   None

 Untagged ports:

    GigabitEthernet1/0/2

1.1.5  display >>

display >>命令用來將顯示信息以追加方式保存到文件。

【命令】

display command >> filename

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【參數】

command:命令關鍵字,取值可以通過輸入?來獲得。

filename:文件名稱,為1~63個字符的字符串。

【使用指導】

display命令顯示的內容通常是統計信息、功能是否使能以及功能的相關參數配置,這些信息在設備運行過程中會隨著時間或者用戶的配置而改變。使用本命令可以將當前顯示信息保存到文件,可供用戶隨時比對和查看。

執行本命令時,如果filename不存在,係統會先創建該文件,再保存。如果filename已存在,則新保存的內容會追加到文件filename的尾部。

【舉例】

# 將display vlan 999的顯示信息以追加方式保存到文件vlan.txt。

<Sysname> display vlan 999 >> vlan.txt

查看vlan.txt的內容,驗證display >>命令的執行效果。

<Sysname> more vlan.txt

VLAN ID: 1

 VLAN type: Static

 Route interface: Not configured

 Description: VLAN 0001

 Name: VLAN 0001

 Tagged ports:   None

 Untagged ports:

    GigabitEthernet1/0/2

 

 VLAN ID: 999

 VLAN type: Static

 Route interface: Configured

 IPv4 address: 192.168.2.1

 IPv4 subnet mask: 255.255.255.0

 Description: For LAN Access

 Name: VLAN 0999

 Tagged ports:   None

 Untagged ports:

    GigabitEthernet1/0/2

1.1.6  display alias

display alias命令用來查看命令別名的相關配置。

【命令】

display alias [ alias ]

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【參數】

alias:表示配置的命令別名。不指定該參數,則顯示所有的已配置的命令別名。

【舉例】

# 查看係統中配置的所有命令別名。

<Sysname> display alias

Index     Alias                Command key

1         access-list          acl

2         end                  return

3         erase                delete

4         exit                 quit

5         hostname             sysname

6         logging              info-center

7         no                   undo

8         shinc                display $1 | include $2

9         show                 display

10        sirt                 display ip routing-table

11        write                save

# 查看別名命令shinc表示的命令字符串。

<Sysname> display alias shinc

Alias                Command key

shinc                display ip $1 | include $2

表1-2  display alias命令顯示信息描述表

字段

描述

Index

索引號

Alias

別名

Command key

命令字符串

 

【相關命令】

·     alias

1.1.7  display history-command

display history-command命令用來顯示當前登錄用戶曆史命令緩衝區中的命令。

【命令】

display history-command

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【使用指導】

用戶登錄設備後,係統會給每個用戶自動分配一個曆史命令緩衝區,用於存放用戶本次登錄成功執行的命令行,以便用戶查看和調用。曆史命令緩存區有大小限製,缺省保存10條命令,用戶也可以通過history-command max-size命令來修改大小。當數目達到上限時,係統會自動刪除最早的記錄,來保存最新成功執行的命令。

如果用戶退出登錄,係統會自動清除該曆史命令緩存區的所有記錄。

【舉例】

# 顯示曆史命令緩存區內保存的命令。

<Sysname> display history-command

  system-view

  vlan 2

  quit

【相關命令】

·     history-command max-size(基礎配置命令參考/登錄設備)

1.1.8  display history-command all

display history-command all命令用來顯示所有登錄用戶曆史命令緩衝區中的命令。

【命令】

display history-command all

【視圖】

任意視圖

【缺省用戶角色】

network-admin

context-admin

【使用指導】

係統中有一個共享曆史命令緩衝區,用於存放所有登錄用戶成功執行的命令行,以便用戶查看(不能調用)。曆史命令緩存區的大小固定為1024條,不可配置。當數目達到上限時,係統會自動刪除最早的記錄,來保存最新成功執行的命令。

即便用戶退出登錄,係統也不會清除共享曆史命令緩存區中該用戶的曆史命令記錄。

【舉例】

# 顯示所有登錄用戶成功執行的曆史命令。

<Sysname> display history-command all

  Date       Time     Terminal   Ip              User

  03/16/2017 20:03:33 vty0       192.168.1.26    **

  Cmd:dis his all

 

  03/16/2017 20:03:29 vty0       192.168.1.26    **

  Cmd:sys

表1-3 display history-command all命令顯示信息描述表

字段

描述

Date

執行命令行的日期

Time

執行命令行的時間

Terminal

執行命令的用戶使用的登錄用戶線

Ip

執行命令的用戶使用的登錄IP

User

如果用戶使用scheme方式登錄設備,該字段顯示為執行命令的用戶使用的登錄用戶名;如果使用其他方式登錄設備,該字段顯示為**

Cmd

執行的命令(和用戶的輸入保持一致)

 

【相關命令】

·     display history-command

1.1.9  display hotkey

display hotkey命令用來顯示係統支持的快捷鍵及其含義。

【命令】

display hotkey

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【舉例】

# 顯示係統支持的快捷鍵及其含義。

<Sysname> display hotkey

----------------- Hotkeys -----------------

           -Defined command hotkeys-

CTRL_G display current-configuration

CTRL_L display ip routing-table

CTRL_O undo debugging all

           -Undefined command hotkeys-

CTRL_T NULL

CTRL_U NULL

           -System-reserved hotkeys-

CTRL_A  Move the cursor to the beginning of the line.

CTRL_B  Move the cursor one character to the left.

CTRL_C  Stop the current command.

CTRL_D  Erase the character at the cursor.

CTRL_E  Move the cursor to the end of the line.

CTRL_F  Move the cursor one character to the right.

CTRL_H  Erase the character to the left of the cursor.

CTRL_K  Abort the connection request.

CTRL_N  Display the next command in the history buffer.

CTRL_P  Display the previous command in the history buffer.

CTRL_R  Redisplay the current line.

CTRL_V  Paste text from the clipboard.

CTRL_W  Delete the word to the left of the cursor.

CTRL_X  Delete all characters from the beginning of the line to the cursor.

CTRL_Y  Delete all characters from the cursor to the end of the line.

CTRL_Z  Return to the User View.

CTRL_]  Kill incoming connection or redirect connection.

ESC_B   Move the cursor back one word.

ESC_D   Delete all characters from the cursor to the end of the word.

ESC_F   Move the cursor forward one word.

ESC_N   Move the cursor down a line.

ESC_P   Move the cursor up a line.

ESC_<   Move the cursor to the beginning of the clipboard.

ESC_>   Move the cursor to the end of the clipboard.

表1-4 display hotkey命令顯示信息描述表

字段

描述

Defined command hotkeys

已定義的快捷鍵

Undefined command hotkeys

未定義的快捷鍵

System-reserved hotkeys

係統保留的快捷鍵。每個保留快捷鍵的作用請參見表1-5

 

表1-5 係統保留的快捷鍵

快捷鍵

功能

<Ctrl+A>

將光標移動到當前行的開頭

<Ctrl+B>

將光標向左移動一個字符

<Ctrl+C>

停止當前正在執行的功能

<Ctrl+D>

刪除當前光標所在位置的字符

<Ctrl+E>

將光標移動到當前行的末尾

<Ctrl+F>

將光標向右移動一個字符

<Ctrl+H>

刪除光標左側的一個字符

<Ctrl+K>

終止呼出的連接

<Ctrl+N>

顯示曆史緩衝區中的下一條命令

<Ctrl+P>

顯示曆史緩衝區中的上一條命令

<Ctrl+R>

重新顯示當前行信息

<Ctrl+V>

粘貼剪貼板的內容

<Ctrl+W>

刪除光標左側連續字符串內的所有字符

<Ctrl+X>

刪除光標左側所有的字符

<Ctrl+Y>

刪除光標所在位置及其右側所有的字符

<Ctrl+Z>

退回到用戶視圖

<Ctrl+]>

終止當前連接

<Esc+B>

將光標移動到左側連續字符串的首字符處

<Esc+D>

刪除光標所在位置及其右側連續字符串內的所有字符

<Esc+F>

將光標向右移到下一個連續字符串之前

<Esc+N>

將光標向下移動一行(輸入回車前有效)

<Esc+P>

將光標向上移動一行(輸入回車前有效)

<Esc+<>

將光標所在位置指定為剪貼板的開始位置

<Esc+>>

將光標所在位置指定為剪貼板的結束位置

 

【相關命令】

·     hotkey

1.1.10  hotkey

hotkey命令用來為快捷鍵指定對應的命令行。

undo hotkey命令用來恢複缺省情況。

【命令】

hotkey { ctrl_g | ctrl_l | ctrl_o | ctrl_t | ctrl_u } command

undo hotkey { ctrl_g | ctrl_l | ctrl_o | ctrl_t | ctrl_u }

【缺省情況】

<Ctrl+G>對應命令display current-configuration(顯示當前配置)。

<Ctrl+L>對應命令display ip routing-table(顯示IPv4路由表信息)。

<Ctrl+O>對應命令undo debugging all(關閉設備支持的所有功能項的調試開關)。

<Ctrl+T>未關聯任何命令行。

<Ctrl+U>未關聯任何命令行。

【視圖】

係統視圖

【缺省用戶角色】

network-admin

context-admin

【參數】

ctrl_g:表示為快捷鍵<Ctrl+G>指定一條命令。

ctrl_l:表示為快捷鍵<Ctrl+L>指定一條命令。

ctrl_o:表示為快捷鍵<Ctrl+O>指定一條命令。

ctrl_t:表示為快捷鍵<Ctrl+T>指定一條命令。

ctrl_u:表示為快捷鍵<Ctrl+U>指定一條命令。

command:快捷鍵關聯的命令行。

【使用指導】

通過快捷鍵用戶可以簡便、快捷的操作設備,使用display hotkey命令可以查看設備支持的所有快捷鍵及其含義。

【舉例】

# 指定命令display tcp statistics的快捷鍵為<Ctrl+T>。

<Sysname> system-view

[Sysname] hotkey ctrl_t display tcp statistics

【相關命令】

·     display hotkey

1.1.11  quit

quit命令用來使用戶從當前視圖退回到上一層視圖。

【命令】

quit

【視圖】

任意視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【使用指導】

如果當前是用戶視圖,執行quit後,會斷開當前連接,退出係統。

【舉例】

# 從接口GigabitEthernet1/0/1視圖退回到係統視圖,再退回到用戶視圖。

[Sysname-GigabitEthernet1/0/1] quit

[Sysname] quit

<Sysname>

1.1.12  repeat

repeat命令用來重複執行曆史記錄命令。

【命令】

repeat [ number ] [ count times ] [ delay seconds ]

【視圖】

任意視圖

【缺省用戶角色】

network-admin

context-admin

【參數】

number:表示重複執行曆史命令的條數,取值範圍為1~256,缺省值為1。

count times:表示重複執行曆史命令的次數,取值範圍為0~4294967295,缺省值為0。如不指定該參數,則曆史命令一直重複執行,直到執行用戶線視圖下設置的終止當前運行任務的快捷鍵才能停止執行該命令,默認的終止快捷鍵為<Ctrl+C>。關於終止當前執行任務的快捷鍵的設置,請參見“基礎配置命令”中的“登錄設備”。

delay seconds:表示重複執行曆史命令的時間間隔,取值範圍為0~4294967295,單位為秒,缺省值為1。

【使用指導】

重複執行曆史命令時,係統將按照曆史命令的下發順序執行。例如,用戶在某視圖下依次執行命令a、b和c後,再執行repeat 3命令,則係統將按照a、b和c的順序重複執行。

如果用戶重複執行的曆史命令中存在交互式命令,需要用戶手動處理此交互式命令,直到交互式命令執行結束,曆史命令才會繼續被重複執行。

實際重複執行曆史命令的條數取如下三者的最小值:

·     通過repeat命令設置的重複執行曆史記錄命令的條數;

·     通過history-command max-size命令設置當前用戶線下最大可以存儲的曆史命令的條數;

·     當前實際存在的曆史命令的條數。

【舉例】

# 重複執行最近2條曆史命令display cpu-usagedisplay clock,重複執行3次,時間間隔10秒。

<Sysname> repeat 2 count 3 delay 10

<Sysname> display cpu-usage

Unit CPU usage:

      33% in last 5 seconds

      32% in last 1 minute

      33% in last 5 minutes

                                                                               

<Sysname> display clock

07:02:18 UTC Thu 06/19/2017

<Sysname> display cpu-usage

Unit CPU usage:

      33% in last 5 seconds

      32% in last 1 minute

      33% in last 5 minutes

                                                                               

<Sysname> display clock

07:02:28 UTC Thu 06/19/2017

<Sysname> display cpu-usage

Unit CPU usage:

      33% in last 5 seconds

      32% in last 1 minute

      33% in last 5 minutes

                                                                               

<Sysname> display clock

07:02:38 UTC Thu 06/19/2017

【相關命令】

·     display history-command

·     escape-key(基礎配置命令參考/登錄設備)

·     history-command max-size(基礎配置命令參考/登錄設備)

1.1.13  return

return命令用來從當前視圖(除Tcl配置視圖和Python shell外的任意非用戶視圖)直接退回到用戶視圖。

【命令】

return

【視圖】

除Tcl配置視圖和Python shell外的任意非用戶視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【使用指導】

在除Tcl配置視圖和Python shell外的任意非用戶視圖下,也可以按快捷鍵<Ctrl+Z>退回到用戶視圖,功能等同於return命令。

Tcl配置視圖和Python shell下退回到用戶視圖的方式分別為:

·     Tcl配置視圖下請使用tclquit返回用戶視圖。

·     在Python shell下請通過執行exit()命令,從Python shell退回到用戶視圖。

【舉例】

# 從接口GigabitEthernet1/0/1視圖退回到用戶視圖。

[Sysname-GigabitEthernet1/0/1] return

<Sysname>

1.1.14  screen-length disable

screen-length disable命令用來關閉當前用戶的分屏顯示功能。

undo screen-length disable命令用來開啟當前用戶的分屏顯示功能。

【命令】

screen-length disable

undo screen-length disable

【缺省情況】

用戶登錄後將遵循用戶線下的screen-length設置。screen-length設置的缺省情況為:允許分屏顯示,下一屏顯示24行數據。

【視圖】

用戶視圖

【缺省用戶角色】

network-admin

context-admin

【使用指導】

分屏顯示功能處於關閉狀態時,會一次顯示所有信息,如果信息較多,則會連續刷屏,不方便立即查看。

該配置隻對當前用戶本次登錄有效,用戶重新登錄後將恢複到缺省情況。

【舉例】

# 關閉當前用戶的分屏顯示功能。

<Sysname> screen-length disable

【相關命令】

·     screen-length (基礎配置命令參考/登錄設備)

1.1.15  system-view

system-view命令用來從用戶視圖進入係統視圖。

【命令】

system-view

【視圖】

用戶視圖

【缺省用戶角色】

network-admin

network-operator

context-admin

context-operator

【舉例】

# 從用戶視圖進入係統視圖。

<Sysname> system-view

System View: return to User View with Ctrl+Z.

[Sysname]

不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!

BOB登陆
官網
聯係我們