Using CLI
Command Modes
The NX-OS style CLI
is organized in a hierarchy of command modes with EXEC mode as the root,
containing a tree of configuration submodes beginning with global configuration
mode. The commands available to you depend on the mode you are in. To obtain a
list of available commands in any mode, type a question mark (?) at the system
prompt.
This table
lists and describes the two most commonly used modes (EXEC and global
configuration) along with an example submode (DNS). The table shows how to
enter and exit the modes, and the resulting system prompts. The system prompt
helps to identify which mode you are in and the commands that are available to
you in that mode.
Mode
|
Access
Method
|
Prompt
|
Exit
Method
|
EXEC
|
From the
APIC prompt, enter
execsh.
|
apic#
|
To exit to
the login prompt, use the
exit command.
|
Global
configuration
|
From EXEC
mode, enter the
configure command.
|
apic(config)#
|
To exit from a configuration submode to its parent mode, use
the
exit command.
To exit from any configuration mode or submode to EXEC mode,
use the
end command.
|
DNS configuration
|
From global configuration mode, enter the
dns command.
|
apic(config-dns)#
|
CLI Command
Hierarchy
Configuration mode
has several submodes, with commands that perform similar functions grouped
under the same level. For example, all commands that display information about
the system, configuration, or hardware are grouped under the
show command,
and all commands that allow you to configure the switch are grouped under the
configure
command.
To execute a command
that is not available in EXEC mode, you navigate to its submode starting at the
top level of the hierarchy. For example, to configure DNS settings, use the
configure
command to enter the global configuration mode, then enter the
dns command.
When you are in the DNS configuration submode, you can query the available
commands. as in this example:
apic1# configure
apic1(config)# dns
apic1(config-dns)# ?
address Configure the ip address for dns servers
domain Configure the domains for dns servers
exit Exit from current mode
fabric Show fabric related information
no Negate a command or set its defaults
show Show running system information
use-vrf Configure the management vrf for dns servers
where Show the current mode
apic1(config-dns)# end
apic1#
Each submode places
you further down in the prompt hierarchy. To view the hierarchy for the current
mode, use the
configure
command, as shown in this example:
apic1# configure
apic1(config)# bgp-fabric
apic1(config-bgp-fabric)# where
configure t; bgp-fabric
apic1(config-bgp-fabric)#
To leave the
current level and return to the previous level, type
exit . To
return directly to the EXEC level, type
end .
EXEC Mode
Commands
When you start a CLI
session, you begin in EXEC mode. From EXEC mode, you can enter configuration
mode. Most EXEC commands are one-time commands, such as show commands, which
display the current configuration status.
Configuration
Mode Commands
Configuration mode
allows you to make changes to the existing configuration. When you save the
configuration, these commands are saved across switch reboots. Once you are in
configuration mode, you can enter a variety of protocol-specific modes.
Configuration mode is the starting point for all configuration commands.
Listing Commands
and Syntax
In any command mode,
you can obtain a list of available commands by entering a question mark (?).
apic1(config-dns)# ?
address Configure the ip address for dns servers
domain Configure the domains for dns servers
exit Exit from current mode
fabric Show fabric related information
no Negate a command or set its defaults
show Show running system information
use-vrf Configure the management vrf for dns servers
where Show the current mode
apic1(config-dns)# end
apic1#
To see a list of commands that begin with a particular character sequence, type those characters followed by a question mark
(?). Do not include a space before the question mark.
apic1(config)# sh ?
aaa Show AAA information
access-list Show Access-list Information
accounting Show accounting information
acllog Show acllog information
. . .
To complete a
command after you begin typing, type a tab.
apic1# qu<TAB>
apic1# quota
To list keywords or
arguments, enter a question mark in place of a keyword or argument. Include a
space before the question mark. This form of help is called command syntax help
because it reminds you which keywords or arguments are applicable based on the
commands, keywords, and arguments you have already entered.
apic1(config-dns)# use-vrf ?
inband-mgmt Configure dns on inband
oob-mgmt Configure dns on out-of-band
apic1(config-dns)#
You can also
abbreviate a command if the abbreviation is unambiguous. In this example, the
configure
command is abbreviated.
apic1# conf
apic1(config)#
Undoing or
Reverting to Default Values or Conditions Using the 'no' Prefix
For many
configuration commands, you can precede the command with the
no keyword to
remove a setting or to restore a setting to the default value. This example
shows how to remove a previously-configured DNS address from the configuration.
apic1(config-dns)# address 192.0.20.123 preferred
apic1(config-dns)# show dns-address
Address Preferred
------------------- ---------
192.0.20.123 yes
apic1(config-dns)# no address 192.0.20.123
apic1(config-dns)# show dns-address
Address Preferred
------------------- ---------
Executing BASH
Commands From the NX-OS Style CLI
To execute a
single command in the bash shell, type
bash -c 'path/command' as shown in this example.
apic1# bash -c '/controller/sbin/acidiag avread'
You can execute a
bash command from any mode or submode in the NX-OS style CLI.
Entering Configuration Text with Spaces or Special
Characters
When a configuration field consists of user-defined text, special
characters such as '$' should be escaped ('\$') or the entire word or string
should be wrapped in single quotes to avoid misinterpretation by Bash.