Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Getting Started: A Quick Tour of the CLI

The following topics can help you get started with the Junos OS CLI to perform configuration changes, switch between operational mode and configuration mode, create a user account, and execute some of the basic commands.


If you need a basic introduction to Junos OS, see the Getting Started Guide for Junos OS. For introductory and overview information specific to Junos OS Evolved, see Introducing Junos OS Evolved. For more in-depth information, as well as to learn how to use Junos OS with Juniper Networks devices, see the Overview for Junos OS.

This Junos OS CLI Guide generally assumes you are at least familiar with the content in the other guides, as well as Junos OS concepts and operation principles in general.

Getting Started with the Junos OS Command-Line Interface

This topic shows you how to start the Junos OS CLI, view the command hierarchy, and make small configuration changes. The related topics listed at the end of this topic provide more detailed information about using the CLI.


Before you begin, make sure your device hardware is set up and Junos OS or Junos OS Evolved is installed. You must have a direct console connection to the device or network access using SSH or Telnet. If your device is not set up, follow the installation instructions provided with the device before proceeding.

To log in to a device and start the CLI:

  1. Log in as root.

    The root login account has superuser privileges, with access to all commands and statements.

  2. Start the CLI:

    The > command prompt shows you are in operational mode. Later, when you enter configuration mode, the prompt will change to #.


If you are using the root account for the first time on the device, remember that the device ships with no password required for root, but the first time you commit a configuration, you must set a root password. Root access is not allowed over a telnet session. To enable root access over an SSH connection, you must configure the system services ssh root-login allow statement.

The CLI includes several ways to get help about commands. This section demonstrates some examples showing how to get help:

  1. Type ? to show the top-level commands available in operational mode.

  2. Type file ? to show all possible completions for the file command.

  3. Type file archive ? to show all possible completions for the file archive command.

Switching Between Junos OS CLI Operational and Configuration Modes

When you monitor and configure a device running Junos OS or Junos OS Evolved, you may need to switch between operational mode and configuration mode. When you change to configuration mode, the command prompt also changes. The operational mode prompt is a right -angle bracket (>) and the configuration mode prompt is a pound or hash sign (#).

To switch between operational mode and configuration mode:

  1. When you log in to the device and type the cli command, you are automatically in operational mode:
  2. To enter configuration mode, type the configure command or the edit command from the CLI operational mode. The prompt in brackets ([edit]), also known as a banner, shows that you are in configuration edit mode at the top of the hierarchy. For example:

    The CLI prompt changes from user@host> to user@host# and a banner appears to indicate the hierarchy level.

  3. You can return to operational mode in one of the following ways:
    • To commit the configuration and exit:

    • To exit without committing:

    When you exit configuration mode, the CLI prompt changes from user@host# to user@host> and the banner no longer appears. You can enter or exit configuration mode as many times as you wish without committing your changes.

  4. To display the output of an operational mode command, such as show, while in configuration mode, issue the run configuration mode command and then specify the operational mode command:

    For example, to display the currently set priority value of the Virtual Router Redundancy Protocol (VRRP) primary device while you are modifying the VRRP configuration for a backup device:

Using Keyboard Sequences to Move Around and Edit the Junos OS CLI

You can use keyboard sequences in the Junos OS command-line interface (CLI) to move around and edit the command line. You can also use keyboard sequences to scroll through a list of recently executed commands. The following table lists some of the CLI keyboard sequences. They are the same as those used in Emacs.

Table 1: CLI Keyboard Shortcuts

Keyboard sequence



Move the cursor back one character.

Esc+b or Alt+b

Move the cursor back one word.


Move the cursor forward one character.

Esc+f or Alt+f

Move the cursor forward one word.


Move the cursor to the beginning of the command line.


Move the cursor to the end of the command line.

Ctrl+h, Delete,

or Backspace

Delete the character before the cursor.


Delete the character at the cursor.


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

Ctrl+u or Ctrl+x

Delete the all characters from the command line.

Ctrl+w, Esc+Backspace,

or Alt+Backspace

Delete the word before the cursor.

Esc+d or Alt+d

Delete the word after the cursor.


Insert the most recently deleted text at the cursor.


Redraw the current line.


Scroll backward through the list of recently executed commands.


Scroll forward through the list of recently executed commands.


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

Esc+/ or Alt+/

Search the CLI history for words for which the current word is a prefix.

Esc+. or Alt+

Scroll backward through the list of recently entered words in a command line.

Esc+number sequence

or Alt+number sequence

Specify the number of times to execute a keyboard sequence.

Configuring a User Account on a Juniper Networks Device

This topic describes how to log on to a device running Juniper Networks device using a root account and configure a new user account. You can configure an account for your own use or create a test account.

To configure a new user account on the device:

  1. Log in as root and enter configuration mode:

    The ([edit]) prompt banner shows that you are in configuration edit mode at the top of the hierarchy.

  2. Change to the [edit system login] section of the configuration:

    The prompt in brackets changes to [edit system login] to show that you are at a new level in the hierarchy.

  3. Now add a new user account:

    This example adds an account nchen (for Nathan Chen).


    In Junos OS Release 12.2 and later, user account names can contain a period (.) in the name. For example, you can have a user account named nathan.chen. However, the username cannot begin or end with a period.

  4. Configure a full name for the account. If the name includes spaces, enclose the entire name in quotation marks (" " ):
  5. Configure an account class. The account class sets the user access privileges for the account:
  6. Configure an authentication method and password for the account:

    When the new password prompt appears, enter a clear-text password that the system can encrypt, and then confirm the new password.

  7. Commit the configuration:

    Configuration changes are not activated until you commit the configuration. If the commit is successful, a commit complete message appears.

  8. Return to the top level of the configuration, and then exit:
  9. Log out of the device:
  10. To test your changes, log back in with the user account and password you just configured:

    When you log in, you should see the new username at the command prompt.

You have successfully used the CLI to view the device status and perform a simple configuration change. See the related topics listed in this section for more information about the Junos OS CLI features.


For complete information about the commands to issue to configure your device, including examples, see the Junos OS and Junos OS Evolved configuration guides.

Using the CLI Editor in Configuration Mode

This topic describes some of the basic commands that you can use to enter configuration mode in the command-line interface (CLI) editor, navigate through the configuration hierarchy, get help, and commit or revert the changes that you make during the configuration session.




Edit Your Configuration  

Enter configuration mode.

When you start the CLI, the device is in operational mode. You must explicitly enter configuration mode. When you do, the CLI prompt changes from user@host> to user@host# and the hierarchy level appears in square brackets.

user@host> configure

Create a statement hierarchy.

You can use the edit command to simultaneously create a hierarchy and move to that new level in the hierarchy. You cannot use the edit command to change the value of identifiers.

edit hierarchy-level value
user@host# edit security zones security-zone myzone
[edit security zones security-zone myzone]

Create a statement hierarchy and set identifier values.

The set command is like edit except that your current level in the hierarchy does not change.

set hierarchy-level value
user@host# set security zones security-zone myzone
Navigate the Hierarchy  

Navigate down to an existing hierarchy level.

edit hierarchy-level
user@host# edit security zones
[edit security zones]

Navigate up one level in the hierarchy.

[edit security zones]
user@host# up
[edit security]

Navigate to the top of the hierarchy.

[edit security zones]
user@host# top
Commit or Revert Changes  

Commit your configuration.

user@host# commit
commit complete

Roll back changes from the current session.

Use the rollback command to revert all changes from the current configuration session. When you run the rollback command before exiting your session or committing changes, the software loads the most recently committed configuration onto the device. You must enter the rollback statement at the edit level in the hierarchy.

user@host# rollback
load complete
Exit Configuration Mode  

Commit the configuration and exit configuration mode.

commit and-quit
user@host# commit and-quit

Exit configuration mode without committing your configuration.

You must navigate to the top of the hierarchy using the up or top commands before you can exit configuration mode.

user@host# exit
The configuration has been changed but not committed
Exit with uncommitted changes? [yes,no] (yes)
Get Help  

Display a list of valid options for the current hierarchy level.

[edit ]
user@host# edit security zones ?
Possible completions:
   <[Enter]>                Execute this command 
> functional-zone      Functional zone 
> security-zone          Security zones   
|                                  Pipe through a command 

Checking the Status of a Juniper Networks Device

In operational mode, you can use show commands to check the status of the device and monitor the activities on the device.

To help you become familiar with show commands:

  • Type show ? to display the list of show commands you can use to monitor the router:

  • Use the show chassis routing-engine command to view the Routing Engine status:

  • Use the show system storage command to view available storage on the device:

Rolling Back Configuration Changes

This topic shows how to use the rollback command to return your uncommitted but revised configuration to the state of the most recently committed Junos OS or Junos OS Evolved configuration. The rollback command is useful if you make configuration changes and then decide not to keep them.

The following procedure shows how to configure an SNMP health monitor on a Juniper Networks device and then return to the most recently committed configuration that does not include the health monitor. When configured, the SNMP health monitor provides the network management system (NMS) with predefined monitoring for file system usage, CPU usage, and memory usage on the device.

  1. Enter configuration mode:

  2. Show the current configuration (if any) for SNMP:

    No snmp statements appear because SNMP has not been configured on the device.

  3. Configure the health monitor:

  4. Show the new configuration:

    The health-monitor statement indicates that SNMP health monitoring is configured on the device.

  5. Enter the rollback configuration mode command to return to the most recently committed configuration:

  6. Show the configuration again to make sure your change is no longer present:

    No snmp configuration statements appear. The health monitor is no longer configured.

  7. Enter the commit command to activate the configuration to which you rolled back:

  8. Exit configuration mode:

You can also use the rollback command to return to earlier configurations.

Configuring a Routing Protocol

This topic provides a sample configuration that describes how to configure an OSPF backbone area that has two SONET interfaces.

The final configuration looks like this:


You can create a shortcut for this entire configuration with the following two commands:

Longer Configuration

This section provides a longer example of creating the previous OSPF configuration. In the process, it illustrates how to use the different features of the CLI.

  1. Enter configuration mode by issuing the configure command:

    Notice that the prompt has changed to a pound or hash sign (#) to indicate configuration mode.

  2. To create the above configuration, you start by editing the protocols ospf statements:
  3. Now add the OSPF area:
  4. Add the first interface:

    You now have four nested statements.

  5. Set the hello and dead intervals.
  6. You can see what is configured at the current level with the show command:
  7. You are finished at this level, so return up a level and view what you have done so far:

    The interface statement appears because you have moved to the area statement.

  8. Add the second interface:
  9. Move up to the top level and review what you have:

    This configuration now contains the statements you want.

  10. Before committing the configuration (and thereby activating it), verify that the configuration is correct:
  11. Commit the configuration to activate it on the device:

Making Changes to a Routing Protocol Configuration

Suppose you decide to use different dead and hello intervals on interface so-0/0/1. You can make changes to the configuration.

  1. Go directly to the appropriate hierarchy level by typing the full hierarchy path to the statement you want to edit:
  2. If you decide not to run OSPF on the first interface, delete the statement:

    Everything inside the statement you deleted was deleted with it. You can also eliminate the entire OSPF configuration by simply entering delete protocols ospf while at the top level.

  3. If you decide to use the default values for the hello and dead intervals on your remaining interface but you want OSPF to run on that interface, delete the hello and dead interval timers:

    You can set multiple statements at the same time as long as they are all part of the same hierarchy (the path of statements from the top inward, as well as one or more statements at the bottom of the hierarchy). This feature can reduce considerably the number of commands you must enter.

  4. To go back to the original hello and dead interval timers on interface so-0/0/1, enter:
  5. You also can recreate the other interface, as you had it before, with only a single entry: