Command Line Interface (CLI)
MLNX-GW is equipped with an industry-standard command line interface (CLI). The CLI is accessed through SSH or Telnet sessions or directly through the console port on the front panel, if it exists.
The CLI can be in one of various modes. Each of the modes makes available a certain group (or level) of commands for execution. The following are some of the CLI configuration modes:
Configuration Mode |
Description |
Standard |
When the CLI is launched, it begins in Standard mode. This is the most restrictive mode and only has commands to query a restricted set of state information. Users cannot take any actions that directly affect the system, nor can they change any configuration. |
Enable |
The "enable" command moves the user to Enable mode. This mode offers commands to view all state information and take actions, such as rebooting the system, but it does not allow any configurations to be changed. The commands accessible in this mode are a superset of those in Standard mode. |
Config |
The "configure terminal" command moves the user from Enable mode to Config mode. Config mode is allowed only for user accounts with the “admin” role or capabilities. This mode has a full, unrestricted set of commands to view anything, take any action, and change any configuration. Its commands are a superset of those in Enable mode. To return to Enable mode, enter the command "exit" or "no configure". Note that moving directly between Standard and Config mode is not possible. |
Config interface management |
Config Interface Management mode is a configuration mode for management interface mgmt0, mgmt1, and loopback. |
Any command mode |
Several commands, such as “show” commands, can be applied within any context. |
To help identify the different parts of a CLI command, the following table explains conventions of presenting the syntax of commands.
Syntax Convention |
Description |
Example |
< > Angled brackets |
Indicate a value/variable that must be replaced. |
<1...65535> or <interface> |
[ ] Square brackets |
Indicate optional parameters. Only one parameter out of the parameters listed with in the brackets can be used—the user cannot have a combination of the parameters unless stated otherwise. |
[destination-ip | destination-port | destination-mac] |
{ } Braces |
Indicate alternatives or variables that are required for the parameter in square brackets. |
[mode {active | on | passive}] |
| Vertical bars |
Identify mutually exclusive choices. |
active | on | passive |
Do not use the angled or square brackets, vertical bar, or braces in command lines. This guide uses these symbols only to show the different entry types.
CLI commands and options are in lowercase and are case-sensitive.
For example, when entering the enable command, "enable" must be all in lowercase; it cannot be ENABLE or Enable. Text entries created are also case-sensitive.
Context-sensitive help may be requested at any time by pressing “?” in the command line. This will show a list of choices for the word that is currently selected or, if nothing has been typed yet, will show a list of top-level commands.
For example, typing "?" in the command line in Standard mode, will provide a link of the following available commands.
gateway > ?
cli Configure CLI shell options
enable Enter enable mode
exit Log out of the CLI
help View description of the interactive help system
no Negate or clear certain configuration options
show Display system configuration or statistics
slogin Log into another system securely using ssh
gateway Configure gateway on system
telnet Log into another system using telnet
terminal Set terminal parameters
traceroute Trace the route packets take to a destination
gateway >
Typing a legal string and then pressing “?” without a space character before it, will provide either a description of the command that was typed so far or the possible command/parameter completions. Typing “?” after a space character and “<cr>” is shown, means that, so far, a complete command has been typed. Pressing Enter (carriage return) will execute the command.
Try the following, to get started:
?
show ?
show c?
show clock?
show clock ?
show interfaces ? (from enable mode)
Enter “help” to view a description of the interactive help system.
Note also that the CLI supports command and/or parameter tab-completions and their shortened forms. For example, you can enter “en” instead of the “enable” command, or “cli cl” instead of “cli clear-history”. In case of ambiguity (in case more than one completion option is a vailable), press Tabs twice to obtain the disambiguation options. Thus, to learn which commands start with the letter “c”, type “c” and click twice on the Tab key to get the following:
gateway # c<tab>
clear cli configure
gateway # c
This signifies that there are three commands that start with the letter “c”: "clear", "cli", and "configure".
The prompt always begins with the hostname of the system. What follows depends on what command mode the user is in. To demonstrate by example, assuming the machine name is “gateway”, the prompts for each of the modes are:
gateway > (Standard mode)
gateway # (Enable mode)
gateway (config) # (Config mode)
The following session shows how to move between command modes:
gateway > (You start in Standard mode)
gateway > enable (Move to Enable mode)
gateway # (You are in Enable mode)
gateway # configure terminal (Move to Config mode)
gateway (config) # (You are in Config mode)
gateway (config) # exit (Exit Config mode)
gateway # (You are back in Enable mode)
gateway # disable (Exit Enable mode)
gateway > (You are back in Standard mode)
Commands entered do not print any response and simply show the command prompt after pressing <Enter>.
If an error is encountered while executing a command, the response will begin with “%”, followed by a description of the error.
Several Config commands use the “no” form of the command to reset a parameter value to its inherited, or default, value.
The command sequence below performs the following:
Displays the current CLI session option.
Disables auto-logout.
Displays the new CLI session options (auto-logout is disabled).
Re-enables auto-logout (after 15 minutes).
// 1. Display the current CLI session options
gateway (config) # show cli CLI current session settings: Maximum line size:8192
Terminal width:157
columns Terminal length:60
rows Terminal type: xterm Auto-logout:15
minutes Paging: enabled Progress tracking: enabled Prefix modes: enabled ...// 2. Disable auto-logout
gateway (config) # no cli session auto-logout// 3. Display the new CLI session options
gateway (config) # show cli CLI current session settings: Maximum line size:8192
Terminal width:157
columns Terminal length:60
rows Terminal type: xterm Auto-logout: disabled Paging: enabled Progress tracking: enabled Prefix modes: enabled ...// 4. Re-enable auto-logout after 15 minutes
gateway (config) # cli session auto-logout15
// 5. Display the final CLI session options
gateway (config) # show cli CLI current session settings: Maximum line size:8192
Terminal width:157
columns Terminal length:60
rows Terminal type: xterm Auto-logout:15
minutes Paging: enabled Progress tracking: enabled Prefix modes: enabled ...Displays the final CLI session options (auto-logout is enabled).
This page provides a key to the meaning and format of angle-bracketed parameters in the commands that are listed in this document.
Parameter |
Description |
<domain> |
A domain name |
<hostname> |
A hostname (e.g., “gateway-1”) |
<ifname> |
An interface name (e.g., “mgmt0”, “mgmt1”, “lo” (loopback), and so forth). |
<index> |
A number to be associated with aliased (secondary) IP addresses. |
<IP address> |
An IPv4 address (e.g., "192.168.0.1") |
<log level> |
A syslog logging severity level. Possible values, from least to most severe, are as follows: “debug”, “info”, “notice”, “warning”, “error”, “crit”, “alert”, “emerg”. |
<GUID> |
Globally unique identifier. A number that uniquely identifies a device or component. |
<MAC address> |
A MAC address. The segments may be 8 bits or 16 bits at a time, and may be delimited by “:” or “.” (e.g., “11:22:33:44:55:66”, “1122:3344:5566”, “11.22.33.44.55.66”, or “1122.3344.5566”). |
<netmask> |
A netmask (e.g., “255.255.255.0”) or mask length prefixed with a slash (e.g., “/24”). Both examples express the same information in different formats. |
<network prefix> |
An IPv4 network prefix specifying a network. Used in conjunction with a netmask to determine which bits are significant. e.g., “192.168.0.0”. |
<regular expression> |
An extended regular expression as defined by the “grep” in the main page. (The value provided here is passed on to “grep -E”.) |
<node id> |
ID of a node belonging to a cluster. This is a numerical value greater than zero. |
<cluster id> |
A string specifying the name of a cluster. |
<port> |
TCP/UDP port number. |
<TCP port> |
A TCP port number in the full allowable range [0...65535]. |
<URL> |
A normal URL, using any protocol that wget supports, including HTTP, HTTPS, FTP, SFTP, and TFTP or a pseudo-URL specifying an scp file transfer. The scp pseudo-URL format is scp://username:password@hostname/path/filename. Note that the path is an absolute path. Paths relative to the user's home directory are not currently supported. Because the implementation of FTP does not support authentication, use SCP or SFTP for that. Note also that omitting “:password” part, may require entering the password in a follow-up prompt, where it can be typed in securely (without the characters being echoed). This prompt will occur if the “cli default prompt empty-password” setting is true; otherwise, the CLI will assume that no password is desired. Including the “:” character, will be taken as an explicit declaration that the password is empty and no prompt will appear. |
CLI Filtration Options “include” and “exclude”
The MLNX-GW CLI supports filtering “show” commands to display lines containing or excluding certain phrases or characters. To filter the outputs of the “show” commands use the following format:
gateway (config) # <show command> | {include | exclude} <extended regular expression> [<ignore-case
>] [next <lines>] [prev <lines>]
The filtering parameters are separated from the show command they filter by a pipe character (“|”). Quotation marks may be used to include or exclude a string including space, and multiple filters can be used simultaneously as shown in the example below.
gateway (config) # <show command> | {include <extended regular expression>} [<ignore-case
>] [next <lines>] [prev <lines>] | exclude <extended regular expression> [<ignore-case
>] [next <lines>] [prev <lines>]]
metrox (config) # <show command> | {include <extended regular expression>} [<ignore-case
>] [next <lines>] [prev <lines>] | exclude <extended regular expression> [<ignore-case
>] [next <lines>] [prev <lines>]]
Example:
gateway (config) # show inventory | include SYSTEM
-----------------------------------------------------
Module Part Number Serial Number
-----------------------------------------------------
gateway (config) # show inventory | exclude SYSTEM
SYSTEM SKY-6200
-R20A1 Default string
CLI Monitoring Option “watch”
MLNX-GW
gateway (config) # <show command> | watch [diff] [interval <1
-100
secs>]
Running this command displays a show-command output that is updated at a time interval specified by the “interval” parameter (2 seconds is the default).
The “diff” parameter highlights the differences between each iteration of the command.
For example, running the command “show clock | watch diff interval 1” yields something similar to the following:
Time: 18
:47
:02
Date: 2020
/07
/05
Time zone: Asia Middle_East Jerusalem (Asia/Jerusalem)
UTC offset: +0300
(UTC plus 3
hours)
With the highlighted black blocks indicating the change that has occurred between one iteration of the command from one second to the next.
To exit “watch” mode, press Ctrl+C.
The “watch” option may be used in conjunction with the “include” and “exclude” options as follows:
gateway (config) # <show command> | {include | exclude} <extended regular expression> | watch [diff] [interval <1
-100
secs>]
It is possible to count the number of lines in an output of a “show” command by using the following command:
gateway (config) # <show command> | count
Example:
gateway (config) # show clock
Time: 16
:05
:43
Date: 2020
/05
/25
Time zone: UTC (Etc/UTC)
UTC offset: same as UTC
# show clock | count
4
CLI “json-print” Option
The MLNX-GW CLI supports printing “show” commands in JSON syntax.
To print the output of the “show” commands as JSON, use the following format:
gateway (config) # <show command> | json-print
Running the command displays an output of the “show” command in JSON syntax structure instead of its regular format. See the following as an example:
gateway (config) # show inventory
-----------------------------------------------------
Module Part Number Serial Number
-----------------------------------------------------
SYSTEM SKY-6200
-R20A1 MT1900X00000
gateway (config) # show inventory | json-print
[
{
"SYSTEM"
: [
{
"Part Number"
: "SKY-6200-R20A1"
,
"Serial Number"
: "MT1900X00000"
}
]
}
]
The “json-print” option cannot be used together with filtering (“include” and “exclude”) and/or monitoring (“watch”).
For more information on JSON usage, please refer to “JSON API”.
CLI Shortcuts
The following table presents the available keyboard shortcuts on the MLNX-GW CLI.
Key Combination |
Description |
Ctrl-a |
Move cursor to beginning of line |
Ctrl-b |
Move cursor backward one character without deleting |
Ctrl-c |
Terminate operation |
Ctrl-d |
If cursor is in the middle of the line, delete one character forward If cursor is at the end of the line, show autocomplete options for current word or word fragment If cursor at an empty line, same as Esc |
Ctrl-e |
Move cursor to end of line |
Ctrl-f |
Move cursor forward one character |
Ctrl-h |
Delete one character backwards from cursor |
Ctrl-i |
Auto-complete current word (same as TAB) |
Ctrl-j |
Return carriage (same as ENTER) |
Ctrl-k |
Delete line after cursor |
Ctrl-l |
Clear screen and show line at the top of terminal window |
Ctrl-m |
Return carriage (same as ENTER) |
Ctrl-n |
Next line (same as DOWN ARROW) |
Ctrl-p |
Next line (same as UP ARROW) |
Ctrl-t |
Transpose the two characters on either side of cursor |
Ctrl-u |
Delete line |
Ctrl-w |
Delete the last word |
Ctrl-y |
Retrieve (“yank”) last item deleted |
Esc b |
Move cursor one word backward |
Esc c |
Capitalizes first letter in word after cursor |
Esc d |
Delete one word forward from cursor |
Esc f |
Move one word forward from cursor |
Esc l |
Change word after cursor to lowercase letters |
Esc Ctrl-h |
Delete one word backward from cursor |
Esc [ A |
Next line (same as DOWN ARROW) |
Esc [ B |
Next line (same as UP ARROW) |
Esc [ C |
Move forward one character from cursor |
Esc [ D |
Move backward one character from cursor |