[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]

Using the Command-Line Interface

This section contains the following topics:

For more information about the CLI, see the JUNOS CLI User Guide.

CLI Command Hierarchy

The CLI commands are organized hierarchically, with commands that perform a similar function grouped together under the same level. For example, all commands that display information about the device system and system software are grouped under the show command, and all commands that display information about the routing table are grouped under the show route command. Figure 1 illustrates a portion of the show command hierarchy.

Figure 1: CLI Command Hierarchy Example

Image g001411.gif

To execute a command, you enter the full command name, starting at the top level of the hierarchy. For example, to display a brief view of the routes in the routing table, use the command show route brief.

The hierarchical organization results in commands that have a regular syntax and provides the following features that simplify CLI use:

Starting the CLI

To start the CLI:

  1. Establish a connection with the device:
  2. Log in using your username and password.

    After you log in, you enter a UNIX shell.

  3. Start the CLI.
    % cli
    user@host>

The presence of the angle bracket (>) prompt indicates the CLI has started. By default, the prompt is preceded by a string that contains your username and the hostname of the router.

To exit the CLI and return to the UNIX shell, enter the quit command.

CLI Operational Mode

The CLI has two modes: operational and configuration. When you log in to the device and the CLI starts, you are at the top level of operational mode.

To view a list of top-level operational mode commands, type a question mark (?) at the command-line prompt.


user@host> ?
Possible completions:   
clear          Clear information in the system   
configure      Manipulate software configuration information 
file           Perform file operations
help           Provide help information   
monitor        Show real-time debugging information   
mtrace         Trace multicast path from source to receiver   
ping           Ping remote target   
quit           Exit the management session   
request        Make system-level requests   
restart        Restart software process   
set            Set CLI properties, date/time, craft interface message   
show           Show system information   
ssh            Start secure shell on another host   
start          Start shell   
telnet         Telnet to another host   
test           Perform diagnostic debugging   
traceroute     Trace route to remote host

At the top level of operational mode are a number of broad groups of CLI commands that are used to perform the following functions:

To control the CLI environment, see Configuring the CLI Environment. To enter configuration mode, see CLI Configuration Mode. For information about the other CLI operational mode functions, see the JUNOS Software Administration Guide.

CLI Configuration Mode

To configure the device, including system parameters, routing protocols, security, interfaces, network management, and user access, you must enter configuration mode. In configuration mode, the CLI provides commands to configure the device, load a text (ASCII) file that contains the device configuration, activate a configuration, and save the configuration to a text file.

You enter configuration mode by entering the configure operational mode command. The CLI prompt changes from user@host> to user@host#.

To view a list of configuration mode commands, type a question mark (?) at the command-line prompt. (You do not need to press Enter after typing the question mark.)


user@host# ?
Possible completions:   
Enter                Execute this command   
activate             Remove the inactive tag from a statement   
annotate             Annotate the statement with a comment   
commit               Commit current set of changes   
copy                 Copy a statement   
deactivate           Add the inactive tag to a statement   
delete               Delete a data element   
edit                 Edit a sub-element   
exit                 Exit from this level   
help                 Provide help information   
insert               Insert a new ordered data element   
load                 Load configuration from ASCII file   
quit                 Quit from this level   
rename               Rename a statement   
rollback             Roll back to previous committed configuration   
run                  Run an operational-mode command   
save                 Save configuration to ASCII file   
set                  Set a parameter   
show                 Show a parameter   
status               Show users currently editing configuration   
top                  Exit to top level of configuration   
up                   Exit one level of configuration  
wildcard             Wildcard operations

The JUNOS software configuration consists of a hierarchy of statements. There are two types of statements: container statements, which contain other statements, and leaf statements, which do not contain other statements. All the container and leaf statements together form the configuration hierarchy.

Each statement consists of a fixed keyword and, optionally, an identifier that you define, such as the name of an interface or a username.

To configure the device or to modify an existing configuration, you add statements to the configuration with the edit and set configuration mode commands. For more information about the CLI configuration editor and configuration mode, see the JUNOS Software configuration guides.

CLI Basics

This section contains the following topics:

Editing Keystrokes

In the CLI, you use keystrokes to move around on and edit the command line, and to scroll through a list of recently executed commands. Table 4 lists some typical CLI editing tasks and the keystrokes that perform them.

Table 4: CLI Editing Keystrokes

Task Category

Action

Keyboard Sequence

Move the cursor.

Move the cursor back one character.

Ctrl-b

Move the cursor back one word.

Esc b

Move the cursor forward one character.

Ctrl-f

Move the cursor forward one word.

Esc f

Move the cursor to the end of the command line.

Ctrl-e

Delete characters.

Delete the character before the cursor.

Ctrl-h, Delete, or Backspace

Delete the character at the cursor.

Ctrl-d

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

Ctrl-k

Delete all characters on the command line.

Ctrl-u or Ctrl-x

Delete the word before the cursor.

Ctrl-w or Esc Backspace

Delete the word after the cursor.

Esc d

Insert recently deleted text.

Insert the most recently deleted text at the cursor.

Ctrl-y

Redraw the screen.

Redraw the current line.

Ctrl-l

Display previous command lines.

Scroll backward through the list of recently executed commands.

Ctrl-p

Scroll forward through the list of recently executed commands.

Ctrl-n

Search the CLI history in reverse order for lines matching the search string.

Ctrl-r

Search the CLI history by typing some text at the prompt, followed by the keyboard sequence. The CLI attempts to expand the text into the most recent word in the history for which the text is a prefix.

Esc /

Repeat keyboard sequences.

Specify the number of times to execute a keyboard sequence. Replace number with a number from 1 through 9, and replace sequence with a keyboard sequence in this table.

Esc number sequence

Command Completion

You do not always have to remember or type the full command or option name for the CLI to recognize it. To display all possible command or option completions, type the partial command followed immediately by a question mark (?).

To complete a command or option that you have partially typed, press Tab or Spacebar. If the partially typed letters uniquely identify a command, the complete command name appears. Otherwise, a message indicates that your entry is ambiguous or invalid. Possible command completions are displayed if your entry is ambiguous.

You can also use command completion on filenames and usernames. To display all possible values, type one or more characters followed immediately by a question mark. To complete these partial entries, press Tab only. Pressing Spacebar does not work.

Online Help

The CLI provides context-sensitive Help at every level of the command hierarchy. The Help information tells you which commands are available at the current level in the hierarchy and provides a brief description of each.

To get Help while in the CLI, type a question mark (?) in one of the following ways:

When you enter the help commands described in Table 5, the CLI displays usage guidelines and summary information for configuration statements and operational mode commands. You can enter help commands in operational or configuration mode.

Table 5: Help Commands

CLI Command

Description

help apropos string

Displays Help based on a text string contained in a statement or command name.

If the string contains spaces, enclose it in quotation marks. You also can specify a regular expression for the string, using standard UNIX-style regular expression syntax.

In configuration mode, this command displays statement names and Help text that match the string specified.

In operational mode, this command displays the following types of commands that match the string specified, plus Help text:

  • Operational mode commands
  • help topic and help reference commands you can enter for more information

For example, to get a list of statements that contain the string traps, enter the help apropos traps command in configuration mode.

help reference string

Displays summary information for configuration statements.

For example, to display summary information for the OSPF hello interval, enter the command help reference ospf hello-interval.

Note: In some cases, multiple Help topics are available for the same configuration statement. When an existing JUNOS statement has been modified for JUNOS Software, two help commands are available—one describing the original JUNOS statement and another describing the updates to that statement for JUNOS Software. To view the Help topic that describes the modifications made for JUNOS Software, enter the help command that contains the string junos-es. For example, to view Help for the access profile profile-name authentication-order statement, enter help reference access authentication-order-junos-es.

help topic string

Displays usage guidelines for configuration statements.

For example, to display usage guidelines for the OSPF hello interval, enter the command help topic ospf hello-interval.

Configuring the CLI Environment

You can configure the CLI environment for your current login session. Your settings are not retained when you exit the CLI.

To display the current CLI settings, enter the show cli command:


user@host> show cli
CLI complete-on-space set to on CLI idle-timeout disabled CLI restart-on-upgrade set to on CLI screen-length set to 49 CLI screen-width set to 132 CLI terminal is 'vt100' CLI is operating in enhanced mode CLI working directory is '/cf/var/home/remote'

To change the CLI environment, use the set cli operational mode command:


user@host> set cli ?
Possible completions:   
complete-on-space    Set whether typing space completes current word   
directory            Set working directory   
idle-timeout         Set maximum idle time before login session ends   
prompt               Set CLI command prompt string   
restart-on-upgrade   Set whether CLI prompts to restart after software upgrade   
screen-length        Set number of lines on screen   
screen-width         Set number of characters on a line   
terminal             Set terminal type

Table 6 shows how you can change the CLI environment features.

Table 6: Configuring the CLI Environment

Environment Feature

CLI Command

Default Setting

Options

Command completion

set cli complete-on-space (on | off)

on—Pressing Tab or Spacebar completes a command.

  • Set off to allow only Tab for command completion.
  • Set on to re-enable Tab and Spacebar for command completion.

Your working directory

set cli directory path8

/cf/var/home/remote

Replace path with the directory you want to enter when you log in to the device.

Minutes of idle time

set cli idle-time minutes

Your session never times out unless your login class specifies a timeout.

  • To enable the timeout feature, replace timeout with a value between 1 and 100,000.
  • To disable the timeout feature, replace timeout with 0.

Your session prompt

set cli prompt string

user@host>

Replace string with the prompt you want. If the prompt contains spaces or special characters, enclose string in quotation marks (“ “).

Restart-after-upgrade prompt

set cli restart-on-upgrade (on | off)

CLI prompts you to restart the device after a software upgrade.

  • Set off to disable the prompt for the session.
  • Set on to reenable the prompt.

Number of CLI output line displayed at once

set cli screen-length length

Variable (depends on terminal type).

  • To change the number of lines displayed on the screen, replace length with a value between 1 and 100,000.
  • To disable the display of a set number of lines, replace length with 0. (This feature can be useful when you are issuing CLI commands from scripts.)

Number of CLI characters displayed on a line

set cli screen-width width

Variable (depends on terminal type).

To change the number of characters displayed on a line, replace width with a value between 0 and 100,000.

Your terminal type.

set cli terminal terminal-type

unknown, or set by console.

Replace terminal-type with one of the following values:

  • ansi
  • vt100
  • small-xterm
  • xterm

[ Contents] [ Prev] [ Next] [ Index] [ Report an Error]