Using the CLI


In the CLI, you type commands on a single line, and they are executed when you press the Enter key. 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 fand provides a brief description of each. To get help while in the CLI, type ? . You do not need to press Enter after typing the question mark.

You do not 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 the tab key or the spacebar. If the partially typed letters begin a string that uniquely identifies a command, the complete command name appears. Otherwise, the possible completions are displayed.

Command completion also applies to other strings, such as filenames and usernames. To display all possible values, type a partial string followed immediately by a question mark. To complete these strings, press the tab key.

When you commit a configuration, the JUNOS software checks the configuration you are committing. If there are no problems, a message indicates that the configuration was accepted. If there are problems, a message indicates where the errors are.

In the top-level CLI commands and in configuration mode, if you type an invalid string ”for example, the name of a command or statement that does not exist ”you see the message "syntax error" or "unknown command." A caret (^) indicates where the error is.

The CLI provides emacs-style keyboard sequences to help you work on the CLI, as shown in Table 5.1.

Table 5.1. CLI Keyboard Sequences
Category Action Keyboard Sequence
Move the cursor. Move the cursor back one character. Ctrl-b
  Move the cursor back one word. Esc-b or Alt-b
  Move the cursor forward one character. Ctrl-f
  Move the cursor forward one word. Esc-f or Alt-f
  Move the cursor to the beginning of the command line. Ctrl-a
  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 , Esc-Backspace , or Alt-Backspace
  Delete the word after the cursor. Esc-d or Alt-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. number can be from 1 through 9. Esc- number sequence or Alt- number sequence

CLI Screen Output

When you issue commands in operational mode, or when you issue the show command in configuration mode, the output appears on the screen. If the output is too long to display on one screen, it is displayed on several screens using a UNIX-like "more" interface as shown in Table 5.2.

Table 5.2. "More" Prompt Keyboard Sequences
Category Action Keyboard Sequence
Get help. Display information about the keyboard sequences you can display at the ---More--- prompt. h
Scroll down. Scroll down one line. Enter , Return , k , Ctrl-m , Ctrl-n , or down arrow
  Scroll down one-half screen. tab , d , Ctrl-d , or Ctrl-x
  Scroll down one whole screen. Space or Ctrl-f
  Scroll down to the bottom of the output. Ctrl-e or G
  Display the output all at once instead of one screen at a time. (Same as specifying the no-more command.) N
Scroll up. Display the previous line of output. j , Ctrl-h , Ctrl-p , or up arrow
  Scroll up one-half screen. u or Ctrl-u
  Scroll up one whole screen. b or Ctrl-b
  Scroll up to the top of the output. Ctrl-a or g
Search. Search forward for a string. / string
  Search backward for a string. ? string
  Repeat the previous search for a string. n
  Search for a text string. You are prompted for the string to match. (Same as specifying the match string command.) m or M
  Search, ignoring a text string. You are prompted for the string to not match. (Same as specifying the except string command.) e or E
Interrupt or end output, redraw the output, and save the output to a file. Interrupt the display of output. Ctrl-C , q , Q , or Ctrl-k
Do not redisplay the CLI prompt immediately after displaying the output, but remain at the ---More--- prompt. (Same as specifying the hold command.) H
  Clear any match conditions and display the complete output. c or C
  Redraw the output on the screen. Ctrl-l
  Save the command output to a file. You are prompted for a filename. (Same as specifying the save filename command.) s or S

Filtering Screen Output

For operational and configuration commands that display output, such as the show commands, you can filter the output (see Table 5.3). When you display help about these commands, one of the options listed is , called a pipe, which allows you to filter the command output. Table 5.4 lists common regular expression operators that you can specify when searching for a string in the output.

Table 5.3. Filtering the Command Output
Action Command
Place command output in a file. user @host> command save filename
Search for a string in the output.

Match a regular expression:

 user@host>  command  match  regular-expression  

Ignore text that matches a regular expression:

 user@host>  command  except  regular-expression  
Compare configuration changes with a prior version.
 user@host# show  compare [  filename  rollback  n  ] 

filename is the full path to a configuration file. n is the index into the list of previously committed configurations.

Statements that are only in the candidate configuration are prefixed with a plus sign (+). Statements that are only in the comparison file are prefixed with a minus sign ( “). Statements that are unchanged are prefixed with a single blank space ( ).

Count the number of lines in the output. user@host> command count
Display all output at once. user@host> command no-more
Retain the output after the last screen. user@host> command hold
Display additional information about the configuration. user@host> show < hierarchy -level> display detail
Filter command output multiple times.
 user@host>  command  match  regular-expression  except  regular-expression  match  other-regular-expression  find regular-expression  hold 
Table 5.4. Common Regular Expression Operators
Operator Match
One of the two terms on either side of the pipe.
^ At the beginning of an expression, denotes where the command begins.
$ Character at the end of a command. Used to denote a command that must be matched exactly up to that point. For example, allow-commands " show interfaces $ " means that the user cannot issue show interfaces detail or show interfaces extensive .
[ ] Range of letters or digits. To separate the start and end of a range, use a hyphen ( - ).
( ) A group of commands, indicating an expression to be evaluated; the result is then evaluated as part of the overall expression.


Juniper Networks Field Guide and Reference
Juniper Networks Field Guide and Reference
ISBN: 0321122445
EAN: 2147483647
Year: 2002
Pages: 185

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net