2. CLI interface

The CLI is an interface for configuring, monitoring, and maintaining the SR Linux. This chapter describes basic features of the CLI and how to use them.

2.1. Accessing and using the CLI

2.1.1. Accessing the CLI

After the SR Linux device is initialized, you can access the CLI using a console or SSH connection. See the SR Linux hardware documentation for information about establishing a console connection and enabling and connecting to an SSH server.

Use the following command to connect to the SR Linux and open the CLI using SSH:

ssh admin@<IP Address>

Example:

ssh admin@172.16.0.3
Hello admin,
Welcome to the srlinux CLI.
Type 'help' (and press <ENTER>) if you need any help using this.
--{ running }--[ ]--

2.1.2. Using the CLI help functions

The CLI help functions (? and help) can assist in understanding command usage and indicate which configuration mode you are in.

Enter a question mark (?) after a command to display the command usage. For example, entering a question mark after the command network-instance, shows its usage.

Example:

network-instance ?
usage: network-instance <name>
Network instances configured on the local system
Positional arguments:
  name              [string] A unique name identifying the network instance
--{ running }--[  ]-- 

Enter help at the top level to show the current configuration mode and details on other configuration modes. For more information about configurations, see Configuration modes.

Example:

help
--------------------------------------------------------------------------------
You are now in the running mode.
Here you can navigate and query the running configuration.
This configuration has been validated, committed and send to the applications.
There are multiple modes you can enter while using the CLI.
Each mode offers its own set of capabilities:
    - running mode: Allows traversing and inspecting of the running configuration.
    - state mode: Allows traversing and inspecting of the state.
    - candidate mode: Allows editing and inspecting of the configuration.
    - show mode: Allows traversing and executing of custom show routines.
To switch mode use 'enter <mode-name>', e.g. 'enter candidate'
To navigate around, you can simply type the node name to enter a context, while
'exit [all]' is used to navigate up.
'{' and '}' are an alternative way to enter and leave contexts.
'?' can be used to see all possible commands, or alternatively,
'<TAB>' can be used to trigger auto-completion.
'tree' displays the tree of possible nodes you can enter.
--------------------------------------------------------------------------------
--{ * running }--[  ]--

2.1.3. Using the CLI auto-complete function

To reduce keystrokes or aid in remembering a command name, use the CLI auto-complete function.

Enter a tab at any mode or level to auto-complete the next command level. If multiple options are available, a popup will appear.

  1. When a command is partially entered, the remainder of the command appears ahead of the prompt in lighter text. Press the Tab key to complete the command.
     
  2. When the Tab key is pressed and there are multiple options, the options are shown:
     

2.1.4. Using the CLI

Use shortcuts to move the cursor on the command line, complete commands, and recall commands previously entered. Shortcuts can also make syntax correction easier. Table 3 lists common shortcuts.

Table 3:  CLI keyboard shortcuts  

Task

Keystroke

Move cursor to the beginning of the line

Ctrl+A

Move cursor to the end of the line

Ctrl+E

Move cursor one character to the right

Ctrl+F or Right arrow key

Move cursor one character to the left

Ctrl+B or Left arrow key

Move cursor forward one word

Esc F

Move cursor back one word

Esc B

Transpose the character to the left of the cursor with the character the cursor is placed on

Ctrl+T

Complete a partial command

Enter the first few letters, then press the Tab key

Recall previous entry in the buffer

Page up key

Navigate one level up within a context. For example:

--{running}--[interface ethernet-1/1 subinterface 1]--

# exit

--{running}--[interface ethernet-1/1]--

Type: exit

Return to the root context. For example:

--{running}--[interface ethernet-1/1 subinterface 1]--

# exit all

--{running}--[ ]--

Type: exit all

2.1.5. Closing the CLI

Close the CLI using one of the following methods:

  1. Press Ctrl+D.
  2. Enter the quit command at the CLI prompt.

2.2. Configuration modes

Configuration modes define how the system is running when transactions are performed. Supported modes are the following:

  1. Candidate – Use this mode to modify a configuration. Modifications are not applied to the running system until a commit command is issued. When committed, the changes are copied to the running configuration and become active.
    There are different types of configuration candidates. See Configuration candidates.
  2. Running – Use this mode to display the currently running or active configuration. Configurations cannot be edited in this mode.
  3. State – Use this mode to display the configuration and operational states. The state mode displays more detailed information than show mode.
  4. Show – Use this mode to display configured features and operational states. The show mode displays less information than state mode.

2.2.1. Configuration candidates

You can modify the candidate configuration in different modes:

  1. Exclusive
  2. Shared
  3. Private
  4. Name

2.2.1.1. Exclusive mode

When entering candidate mode, if you specify the exclusive keyword, it locks out other users from making changes to the candidate configuration.

You can enter candidate exclusive mode only under the following conditions:

  1. The current shared candidate configuration has not been modified.
  2. There are no other users in candidate shared mode.
  3. No other users have entered candidate exclusive mode.

2.2.1.2. Shared mode

By default, the candidate configuration is in shared mode. This allows multiple users to modify the candidate configuration concurrently. When the configuration is committed, the changes from all of the users are applied.

A default candidate is defined per user (see Name mode).

Use caution when allowing multiple users access to the candidate configuration at the same time. If one user commits the configuration, that commits the changes made by any other users who have modified the current candidate configuration.

2.2.1.3. Private mode

A private candidate allows multiple users to modify a configuration; however when a user commits their changes, only the changes from that user are committed. When a private candidate is created, private datastores are created and a snapshot is taken from the running database to create a baseline.

When starting a private candidate, a default candidate is defined per user with the name ‘private-<username>’ unless a unique name is defined (see Name mode).

2.2.1.4. Name mode

Candidate types support an optional name. This allows multiple users to share environments.

When a candidate is created with a name specified, a new entry is created in the /system/configuration/candidate[] list. Other users can enter the same candidate (if the candidate type is shared) using this name.

if no name is specified, then the name ‘default’ is used. This means the global shared candidate can be accessed by entering enter candidate name default or just enter candidate, For private candidates the name ‘default’ is not used (since private candidates share a list with shared candidates). Instead, private candidates are created with the name "private-<username>".

Named candidates are automatically deleted when there are no active sessions present and they are empty, or after 7 days of no session activity. This 7-day default is configurable in the /system/configuration/idle-timeout field.

2.2.2. Setting the configuration mode

After logging in to the CLI, you are initially placed in running mode. Table 4 describes the commands to change between modes.

Table 4:    Commands to change configuration mode

To enter this mode:

Type this command:

Candidate shared

enter candidate

Candidate mode for named shared candidate

enter candidate name <name>

Candidate private

enter candidate private

Candidate mode for named private candidate

enter candidate private name <name>

Candidate exclusive

enter candidate exclusive

Exclusive mode for named candidate

enter candidate exclusive name <name>

Running

enter running

State

enter state

Show

enter show

For example, to change from running to a shared candidate mode (using the default)’:

--{ running }--[  ]--
enter candidate
--{ * candidate shared default}--[  ]--

The asterisk (*) next to the mode name indicates that the candidate configuration has changes that have not yet been committed.

To switch between candidate shared and candidate exclusive modes, you must first switch to a different configuration mode (for example, running mode) before entering candidate shared or exclusive mode. For example:

--{ running }--[  ]--
enter candidate exclusive
--{ candidate exclusive }--[  ]--
Are you sure? (y/[n]):
enter running
--{ running }--[  ]--
enter candidate
--{ candidate shared default}--[  ]--

To enter candidate mode for a named configuration candidate, you specify the name of the configuration candidate. For example:

--{ running }--[  ]--
enter candidate name cand1
--{ candidate shared cand1}--[  ]--

2.2.3. Managing configuration conflicts

When a user enters candidate mode, the system creates two copies of the running datastore: one is modifiable by the user, and the other serves as a baseline. The modifiable datastore and the baseline datastore are collectively known as a configuration candidate.

The baseline command can assist in managing conflicts and uses the following arguments:

  1. baseline update - Performs an update of the complete baseline datastore. pulling in any changes that occurred in the running datastore since the baseline snapshot was taken.
  2. baseline diff - Shows baseline configuration changes with options to refine by area.
  3. baseline check - Performs a dry-run baseline check, and if conflicts are detected, an informational or warning message is generated.

2.2.4. Committing a configuration in candidate mode

Changes made during a configuration modification session do not take effect until a commit command is issued. Use the commit command in candidate mode only.

  1. Enter candidate mode:
    # enter candidate
  2. Enter configuration commands.
  3. Enter the commit command when with the required option (see Table 5).
    Table 5:  commit command options 

    Option

    Action

    Permitted additional arguments

    commit now

    Apply the changes, exit candidate mode, and enter running mode.

    NA

    commit stay

    Apply the changes and then remain in candidate mode.

    commit stay [save] [comment] [confirmed]

    commit save

    Apply the changes and automatically save the commit to the startup configuration. Can be used other arguments except now (e.g., commit stay save).

    commit [stay] [checkpoint] save [confirmed] [comment]

    commit checkpoint

    Apply the changes and cause an automatic checkpoint after the commit succeeds.

    commit [stay] [now] checkpoint [save] [confirmed]

    commit validate

    Verify that a propose configuration change passes a management server validation.

    NA

    commit comment <comment>

    Use with other keywords (except validate) to add a user comment (e.g. commit stay comment <comment> where <comment> is a quoted string, 1-255 characters.

    commit [stay] [save] [checkpoint] [confirmed] comment

    commit confirmed

    commit confirmed [timeout]

    commit confirmed [accept | reject]

    Apply the changes, but requires an explicit confirmation to become permanent. If the explicit confirmation is not issued within a specified time period, all changes are automatically reverted.

    The timeout period default is 600 seconds (10 mins.), or can be provisioned with a value of 1-86400 sec.). The timeout parameter cannot be used with the accept or reject parameter.

    Prior to the timer expiring, the accept parameter explicitly confirms and applies the changes. With no timer running, the reject parameter explicitly rejects the changes.

    commit [checkpoint] [save] [stay] [comment] confirmed

Example:

This example shows the commit stay option:

enter candidate
--{ candidate shared default}--[  ]--
interface ethernet-1/1 subinterface 1
--{ * candidate shared default}--[ interface ethernet-1/1 subinterface 1 ]--
 
commit stay
All changes have been committed. Starting new transaction.
 
--{ candidate shared default}--[ interface ethernet-1/1 subinterface 1 ]--

Example:

This example shows the commit confirmed option with a custom timeout followed by an accept action.

--{ * candidate shared default}--[  ]--
# commit confirmed timeout 86400
Commit confirmed (automatic rollback in a day)
All changes have been committed. Leaving candidate mode.
--{ running }--[  ]--
 
# commit confirmed accept
Info: Commit confirmed, automatic rollback cancelled
--{ candidate shared default}--[  ]--
#

2.2.5. Deleting configurations

Use the delete command to delete configurations while in candidate mode.

Example:

The following example displays the system banner configuration, deletes the configured banner, then displays the resulting system banner configuration:

--{ candidate shared default}--[  ]--
info system banner
    system {
        banner {
            login-banner "Welcome to SRLinux!"
        }
    }
--{ candidate shared default}--[  ]--
delete system banner
--{ candidate shared default}--[  ]--
info system banner
    system {
        banner {
        }
    }

2.2.6. Annotating the configuration

To aid in reading a configuration, you can add comments or descriptive annotations. The annotations are indicated by !!! in displayed output.

You can enter a comment either directly from the command line or by navigating to a CLI context and entering the comment in annotate mode.

Examples:

The following example adds a comment to an ACL configuration. If there is already a comment in the configuration, the new comment is appended to the existing comment.

--{ candidate shared default}--[  ]--
acl ipv4-filter ip_tcp !! "Filter TCP traffic"

To replace the existing comment, use !!! instead of !! in the command.

The following example adds the same comment to the ACL by navigating to the context for the ACL and entering the comment in annotate mode:

--{ * candidate shared default}--[  ]--
acl ipv4-filter ip_tcp
--{ * candidate shared default}--[ acl ipv4-filter ip_tcp ]--
annotate
Press [Meta+enter] or [Esc] followed by [Enter] to finish
-> Filter TCP traffic

You can enter multiple lines in annotate mode. To exit annotate mode, press Esc, then the Enter key.

In CLI output, the comment is displayed in the context it was entered. For example:

--{ running }--[  ]--
info acl
    acl {
        ipv4-filter ip_tcp {
            !!! Filter TCP traffic
            entry 100 {
                action {
                    drop {
                        log true
                    }
                }
            }
            entry 110 {
                action {
                    accept {
                        log true
                    }
                }
            }
        }
    }

To remove a comment, enter annotate mode for the context and press Esc then Enter without entering any text.

2.2.7. Discarding a configuration in candidate mode

You can discard previously applied configurations with the discard command. Use the discard command in candidate mode only.

  1. To discard the changes and remain in candidate mode with a new candidate session, enter discard stay.
  2. To discard the changes, exit candidate mode, and enter running mode, enter discard now.

Example:

All changes have been committed. Starting new transaction.
 
--{ candidate shared }--[ interface ethernet-1/1 subinterface 1 ]--
discard stay
--{ candidate shared }--[ interface ethernet-1/1 subinterface 1 ]--

2.3. Using administrative commands

The common administrative CLI commands in this section can help you understand a current configuration and perform routine configuration tasks.

2.3.1. Pinging a destination IP address

Use the ping (IPv4) or ping6 (IPv6) command to contact an IP address. Use this command in any mode.

Example:

--{ running }--[  ]--
ping 192.168.1.1 network-instance default
Pinging 192.168.1.1 in srbase-default
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.032 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.030 ms
^C
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6165ms
rtt min/avg/max/mdev = 0.027/0.030/0.033/0.005 ms

2.3.2. Tracing the path to a destination

To display the path a packet takes to a destination, use the traceroute (IPv4) or traceroute6 (IPv6) command.

Example:

--{ running }--[  ]--
traceroute 1.1.1.1  network-instance mgmt
Using network instance srbase-mgmt
traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
 1  172.18.18.1 (172.18.18.1)  1.268 ms  1.260 ms  1.256 ms
 2  172.21.40.1 (172.21.40.1)  1.253 ms  1.848 ms  1.851 ms
 3  172.22.35.230 (172.22.35.230)  1.835 ms  1.834 ms  1.828 ms
 4  66.201.62.1 (66.201.62.1)  3.222 ms  3.222 ms  3.216 ms
 5  66.201.34.17 (66.201.34.17)  5.474 ms  5.475 ms  5.480 ms
 6  * * *
 7  206.81.81.10 (206.81.81.10)  32.577 ms  32.542 ms  32.400 ms
 8  1.1.1.1 (1.1.1.1)  22.627 ms  22.637 ms  22.638 ms

To trace the route using TCP SYN packets rather than UDP or ICMP echo packets, use the tcptraceroute command.

2.3.3. Using bash mode

From within the CLI, use the bash command to enter the bash shell. Use this command in any mode. To exit the bash shell and return to the CLI, enter exit.

Example:

--{ running }--[  ]--
# bash
[root@3-node_srlinux-A /]# ls
anaconda-post.log  dev            etc   lib    media  opt   root  sbin  sys   tmp  var
bin                entrypoint.sh  home  lib64  mnt    proc  run   srv   tini  usr
[root@3-node_srlinux-A /]# exit
logout
--{ running }--[  ]--
#

You can use the bash command to enter Linux commands directly from the SR Linux CLI prompt. For example:

--{ running }--[  ]--
bash cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.18.5     3-node-srlinux-A
### SRLINUX - ANYTHING MODIFIED BEYOND THIS POINT WILL BE OVERWRITTEN ###
127.0.0.1 3-node-srlinux-A
### SRLINUX FOOTER ###

2.3.4. Setting commands to execute periodically

To set a command to execute periodically, use the watch command. The watch command can be used with any valid command based on the current context. Output redirection is supported.

When used with a CLI command, the first page of output displays. The command will re-execute every 2 seconds, or you can optionally provision the interval with a value between 1 - 3600 seconds. The command also p”rovides an option to highlight the differences that occur between each commands execution.

To exit the watch command, enter Ctrl-C.

Examples:

To execute the command show system sflow status every 4 seconds, enter the following command. The command must be surrounded by double quotes.

--{ candidate shared default}--[  ]--
watch "show system sflow status" interval 4
Execute every 4 secs times : show system sflow status  (Executed 3 times, 01:58:43PM
---------------------------------------------------------------------------------
Admin State            : enable
Sample Rate            : 1
Sample Size            : 256
Total Samples          : 0
Total Collector Packets: 346338
-------------------------------------------------------------------------------
  collector-id     : 1
  collector-address: 100.1.3.2
  network-instance : default
  source-address   : 10.0.0.1
  port             : 6219
  next-hop         : 192.35.1.1
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

Note in the upper right of the message is an indication of how many times the command has executed.

2.3.5. Displaying configuration details

The info command to display the configuration. Entering the info command from the root context displays the entire configuration, or the configuration for a specified context. Entering the command from within a context limits the display to the configuration under that context. Use this command in candidate or running mode.

Examples:

To display the entire configuration, enter info from the root context:

--{ candidate shared default}--[  ]--
info
<all the configuration is displayed>
--{ candidate }--[  ]--

To display the configuration for a specific context, enter info and specify the context:

--{ candidate shared default}--[  ]--
info system lldp
    system {
        lldp {
            admin-state enable
            hello-timer 600
            management-address mgmt0.0 {
                type [
                    IPv4
                ]
            }
            interface mgmt0 {
                admin-state disable
            }
        }
    }
--{ candidate }--[  ]--

From a context, use the info command to display the configuration under that context:

--{ candidate shared default}--[  ]--
system lldp
--{ candidate }--[ system lldp ]--
info
    admin-state enable
    hello-timer 600
    management-address mgmt0.0 {
        type [
            IPv4
        ]
    }
    interface mgmt0 {
        admin-state disable
    }
--{ candidate }--[ system lldp ]--

Use the as-json option to display JSON-formatted output:

--{ candidate }--[ system lldp ]--
# info | as json
{
  "admin-state": "enable",
  "hello-timer": "600",
  "management-address": [
    {
      "subinterface": "mgmt0.0",
      "type": [
        "IPv4"
      ]
    }
  ],
  "interface": [
    {
      "name": "mgmt0",
      "admin-state": "disable"
    }
  ]
}

Use the detail option to display values for all parameters, including those not specifically configured:

--{ candidate shared default}--[ system lldp ]--
info detail
    admin-state enable
    hello-timer 600
    hold-multiplier 4
    management-address mgmt0.0 {
        type [
            IPv4
        ]
    }
    interface mgmt0 {
        admin-state disable
    }

Use the flat option to display the output as a series of set statements, omitting indentation for any sub-contexts:

--{ candidate shared default}--[ system lldp ]--
info flat
set / system lldp admin-state enable
set / system lldp hello-timer 600
set / system lldp management-address mgmt0.0
set / system lldp management-address mgmt0.0 type [ IPv4 ]
set / system lldp interface mgmt0
set / system lldp interface mgmt0 admin-state disable

Use the depth option to display parameters with a specified number of sub-context levels:

--{ candidate shared default}--[ system lldp ]--
info depth 0
    admin-state enable
    hello-timer 600
--{ candidate shared default}--[ system lldp ]--
info depth 1
    admin-state enable
    hello-timer 600
    management-address mgmt0.0 {
        type [
            IPv4
        ]
    }
    interface mgmt0 {
        admin-state disable
    }

2.3.6. Displaying the command tree hierarchy

Use the tree command to display the tree hierarchy for all available nodes you can enter. Entering the tree command from the root context displays the entire tree hierarchy. Entering the command from a context limits the display to the nodes under that context.Use this command in candidate or running mode.

--{ candidate shared default}--[ ]--
# tree
<root>
+-- acl
|   +-- ipv4-filter
|   |   +-- description
|   |   +-- subinterface-specific
|   |   +-- statistics-per-entry
|   |   +-- entry
|   |       +-- description
|   |       +-- action
|   |       |   +-- accept
|   |       |   |   +-- log
|   |       |   +-- drop
|   |       |       +-- log
|   |       +-- match
|   |           +-- destination-address
|   |           +-- fragment
|   |           +-- first-fragment
|   |           +-- protocol
|   |           +-- source-address
.
.
.
.

2.3.7. Displaying the command tree hierarchy

To display the state of the configuration, enter the info from state command in candidate or running mode, or the info command in state mode.

Examples:

To display state information for a specified context from modes that are not state mode:

--{ candidate shared default}--[  ]--
info from state routing-policy policy bgp-export-policy
    routing-policy {
        policy bgp-export-policy {
            statement 999 {
                action {
                    accept {
                    }
                }
            }
        }
    }
--{ candidate }--[  ]--

To display state information for a specified context from state mode:

--{ candidate shared shared default}--[  ]--
enter state
--{ state }--[  ]--
info routing-policy policy bgp-export-policy
    routing-policy {
        policy bgp-export-policy {
            statement 999 {
                action {
                    accept {
                    }
                }
            }
        }
    }
--{ state }--[  ]--

2.3.8. Executing configuration statements from a file

You can execute configuration statements from a source file consisting of set statements such as those generated by the info flat command (see Displaying configuration details). The SR Linux reads the file and executes each configuration statement line-by-line. You can optionally commit the configuration automatically after the file is read.

Example:

The following example executes a configuration from a specified file:

--{ running }--[  ]--
source config.cfg
Sourcing commands from 'config.cfg'
Executed 20 lines in 1.6541 seconds from file config.cfg

Use the auto-commit option to commit the configuration after the commands in the source file are executed.

2.3.9. Collecting technical support data

Collect technical support data using the tech-support command. Use this command in any configuration mode.

Example:

--{ candidate shared default}--[  ]--
tech-support
Waiting 5 seconds for apps to dump the reports in /tmp/admintech-report-2019_06_19_20_26_05.zip
Finished collecting in 5s
Admin tech report has been generated at /tmp/admintech-report-2019_06_19_20_26_05.zip
--{ candidate }--[  ]--

You can access the saved file from the bash shell. For example:

--{ running }--[  ]--
bash
[root@3-node_srlinux-A /]# cd /tmp
[root@3-node_srlinux-A tmp]# ls -l
total 6012
-rw-r--r-- 1 root root 6110160 Jun 19 20:26 admintech-report-2019_06_19_20_26_05.zip
[root@3-node_srlinux-A tmp]# exit
logout
--{ running }--[  ]--

2.4. Formatting and filtering CLI output

You can display output from SR Linux CLI commands in text, JSON, or table format, and you can filter the output using Linux tools such as grep. You can direct filtered output to a specified file in a specified format.

2.4.1. Specifying output format

You can display output from SR Linux CLI commands as lines of text, in JSON format, or in a table. By default, output is displayed as lines of text, but you can configure output to be displayed in JSON format by default. See Configuring the CLI output format.

Examples:

The following example displays the output of the show version command as lines of text:

--{ running }--[  ]--
show version | as text
--------------------------------------------------------------------------------
Hostname          : 3-node-srlinux-A
Chassis Type      : 7250 IXR-10
Part Number       : Sim Part No.
Serial Number     : Sim Serial No.
System MAC Address: 12:12:02:FF:00:00
Software Version  : v19.11.1
Build Number      : 291-g4664705
Architecture      : x86_64
Last Booted       : 2019-12-07T00:34:48.942Z
Total Memory      : 16396536 kB
Free Memory       : 5321932 kB
--------------------------------------------------------------------------------

The following example displays the output of the show version command in JSON format:

--{ running }--[  ]--
show version | as json
{
  "basic system info": {
    "Hostname": "3-node-srlinux-A",
    "Chassis Type": "7250 IXR-10",
    "Part Number": "Sim Part No.",
    "Serial Number": "Sim Serial No.",
    "System MAC Address": "12:12:02:FF:00:00",
    "Software Version": "v19.11.1",
    "Build Number": "291-g4664705",
    "Architecture": "x86_64",
    "Last Booted": "2019-12-07T00:34:48.942Z",
    "Total Memory": "16396536 kB",
    "Free Memory": "5319448 kB"
  }
}

The following example displays the output of the show version command as a table:

--{ running }--[  ]--
show version | as table
+----------+----------+-------+--------+--------+----------+----------+----------+
| Hostname | Chassis  | Part  | Serial | System | Software | Architec |   Last   |
|          |   Type   | Number| Number |  MAC   | Version  |   ture   |  Booted  |
|          |          |       |        | Address|          |          |          |
+==========+==========+=======+========+========+==========+===========+=========+
| 3-node-s | 7250     | Sim Pa| Sim    |12:12:05| v19.11.1 | x86_64   | 2019-12- |
| rlinux-A | IXR-10   |rt No. | Serial |:FF:00:0|          |          | 07T00:34 |
|          |          |       | No.    |0       |          |          | :48.942Z |
+----------+----------+-------+--------+--------+----------+----------+----------+

2.4.2. Using Linux output modifiers

Output from SR Linux CLI commands can be piped to standard Linux tools, including grep, more, head, and tail.

Examples:

The following example pipes the output of the show interface command to grep so that only lines with mgmt0 appear in the output:

--{ running }--[  ]--
show interface | grep mgmt0
mgmt0 is up, speed None, type None
  mgmt0.0 is up

The following example pipes the output of the show interface command to more to display one page of output at a time:

--{ running }--[  ]--
show interface | more
===================================================================================
ethernet-1/10 is up, speed 100G, type 100GBASE-CR4 CA-L
  ethernet-1/10.1 is up
    Encapsulation: null
    IPv4 addr    : 192.35.1.0/31 (static)
    IPv6 addr    : 2001:192:35:1::/127 (static, preferred)
    IPv6 addr    : fe80::22e0:9cff:fe78:e2ea/64 (link-layer, preferred)
-----------------------------------------------------------------------------------
ethernet-1/21 is up, speed 100G, type 100GBASE-CR4 CA-L
  ethernet-1/21.1 is up
    Encapsulation: null
    IPv4 addr    : 192.45.1.254/31 (static)
    IPv6 addr    : 2001:192:45:1::fe/127 (static, preferred)
    IPv6 addr    : fe80::22e0:9cff:fe78:e2f5/64 (link-layer, preferred)
-----------------------------------------------------------------------------------
ethernet-1/22 is up, speed 100G, type 100GBASE-CR4 CA-L
  ethernet-1/22.1 is up
    Encapsulation: null
    IPv4 addr    : 192.45.3.254/31 (static)
    IPv6 addr    : 2001:192:45:3::fe/127 (static, preferred)
    IPv6 addr    : fe80::22e0:9cff:fe78:e2f6/64 (link-layer, preferred)
-----------------------------------------------------------------------------------
ethernet-1/3 is up, speed 100G, type 100GBASE-CR4 CA-L
  ethernet-1/3.1 is up
    Encapsulation: null
    IPv4 addr    : 192.57.1.1/31 (static)
    IPv6 addr    : 2001:192:57:1::1/127 (static, preferred)
    IPv6 addr    : fe80::22e0:9cff:fe78:e2e3/64 (link-layer, preferred)
-----------------------------------------------------------------------------------
--More--

The following example pipes the output of the show interface command to head to display only the first 8 lines:

--{ running }--[  ]--
show interface | head --lines 8
===================================================================================
ethernet-1/10 is up, speed 100G, type 100GBASE-CR4 CA-L
  ethernet-1/10.1 is up
    Encapsulation: null
    IPv4 addr    : 192.35.1.0/31 (static)
    IPv6 addr    : 2001:192:35:1::/127 (static, preferred)
    IPv6 addr    : fe80::22e0:9cff:fe78:e2ea/64 (link-layer, preferred)
-----------------------------------------------------------------------------------

2.4.3. Directing output to a file

You can direct the output of SR Linux CLI commands to a specified file. The output can be saved as text, in table format, or in JSON format.

Example:

The following example directs the output of the show interface command to a file. The output is saved in JSON format.

--{ running }--[  ]--
show interface | as json > show_interface.json

Use > to create a new file with the specified filename; if the file already exists, it is replaced. Use >> to append the output to the specified file if it exists.

You can access the file using bash mode. For example:

--{ * running }--[  ]--
bash
[bob@3-node-srlinux-A /]# more show_interface.json
{
  "interfaces": [
    {
      "Interface": "ethernet-1/1",
      "subinterfaces": [
        {
          "Subinterface": "ethernet-1/1.1",
          "Oper": "up",
          "IPv4 Addresses": "192.168.11.1/30",
          "IPv6 Addresses": "2001:1::192:168:11:1/126, fe80::1012:5ff:feff:0/64"
        }
      ]
    },
    {
--More--(42%)

2.5. Customizing the CLI environment

You can optionally configure the SR Linux CLI environment to change settings such as the command prompt, contents of the bottom toolbar, and the default format for displayed output. You can create aliases for CLI commands. The CLI environment settings can be saved to the default SR Linux configuration or to a specified file and subsequently loaded and applied to the current CLI session.

2.5.1. Configuring the CLI prompt

By default, the SR Linux CLI prompt consists of two lines of text, indicating with an asterisk whether the configuration has been modified, the current mode and session type, the current CLI context, and the host name of the SR Linux device, in the following format:

--{ modified? mode_and_session_type }--[ context ]--
hostname#

For example:

--{ * candidate shared }--[ acl ]--
3-node-srlinux-A#

You can configure the SR Linux prompt to include information such as the user name or session ID of the CLI session, the number of changes made to the configuration, and the current local time.

Example:

The following example adds the local time and session user name to the SR Linux CLI prompt.

--{ candidate shared default}--[  ]--
environment prompt "--{{ {modified}{mode_and_session_type} }}--[ {pwc} ]--{time}--\n{user}@{host}# "

In the example, the local time is configured with the {time} keyword, and the session user name is configured with the {user} keyword. The line break is configured with \n. Use the environment prompt ? command to display the keywords that you can configure in the SR Linux CLI prompt.

After you enter this command, the CLI prompt looks like the following:

--{ * candidate shared default}--[ acl ]--Wed 03:07PM--
bob@3-node-srlinux-A#

2.5.2. Configuring the bottom toolbar text

By default, the text that appears at the bottom of the terminal window in SR Linux CLI sessions displays the current mode and session type, whether the configuration has been modified, the user name and session ID of the current AAA session, and the local time, in the following format:

Current mode: modified? mode_and_session_type aaa_user (aaa_session_idtime

For example:

Current mode: * candidate shared                          root (36)  Wed 09:52PM

You can configure the bottom toolbar to include information such as the number of changes made to the configuration and the host name.

Example:

The following example adds the number of changes made to the configuration and the host name to the bottom toolbar.

--{ candidate shared default}--[  ]--
environment bottom-toolbar "Current mode: {modified_with_change_count}{mode_and_session_type} | {aaa_user}@{host} ({aaa_session_id})  {time}"

In the example, the number of configuration changes is configured with the {modified_with_change_count} keyword, and the host name is configured with the {host} keyword. Use the environment bottom-toolbar ? command to display the keywords that you can configure in the bottom toolbar.

After you enter this command, the bottom toolbar looks like the following:

Current mode: *10 candidate shared       root@3-node-srlinux-A (36)  Wed 10:18PM

2.5.3. Configuring the SR Linux CLI engine type

The SR Linux features two versions of the CLI engine: advanced and basic. The advanced CLI engine is enabled by default; it includes the following features:

  1. Displays a toolbar at the bottom of the terminal window. See Configuring the bottom toolbar text.
  2. Includes the command auto-complete feature, as described in Using the CLI auto-complete function.
  3. Allows you to select command options by pressing the Tab key to display the options in a popup, then using the arrow keys to select an option.
  4. Displays descriptions of command options when you press the ? key.

The basic CLI engine includes a limited set of features compared to the advanced version:

  1. Omits the bottom toolbar.
  2. Does not present a selectable list of options when you press the Tab key.
  3. Displays descriptions of command options when you press the ? key (and press Enter), but only at the # prompt for the current context.

If necessary, you can configure the SR Linux to use the basic CLI engine instead of the advanced CLI engine for CLI sessions.

Example:

The following example configures the SR Linux to use the basic CLI engine for CLI sessions:

--{ candidate shared default}--[  ]--
environment cli-engine type basic

2.5.4. Configuring the CLI output format

You can configure the output of CLI commands to be displayed as either text or in JSON format.

Example:

The following example configures CLI command output to be displayed in JSON format.

--{ candidate shared default}--[  ]--
environment output-format json

Subsequent command output is displayed in JSON format by default. For example:

--{ running }--[  ]--
show version
{
  "basic system info": {
    "Hostname": "3-node-srlinux-A",
    "Chassis Type": "7250 IXR-10",
    "Part Number": "Sim Part No.",
    "Serial Number": "Sim Serial No.",
    "System MAC Address": "12:12:02:FF:00:00",
    "Software Version": "v19.11.1",
    "Build Number": "291-g4664705",
    "Architecture": "x86_64",
    "Last Booted": "2019-12-07T00:34:48.942Z",
    "Total Memory": "16396536 kB",
    "Free Memory": "5319448 kB"
  }
}

2.5.5. Configuring CLI command aliases

As a shortcut for entering commands in the CLI, you can configure CLI command aliases. The alias can include one or more CLI command keywords and arguments.

Example:

The following example configures the alias display interface for the SR Linux command info interface <name> subinterface <index> | as table:

--{ candidate shared default}--[  ]--
environment alias "display interface" "info / interface {} subinterface {subinterface} | as table"

In the example, the display interface alias consists of the keywords info interface, arguments to specify an interface name and subinterface number, and keywords to display the output as a table. The alias name and aliased command are each enclosed in quotes. The arguments are enclosed in braces ({ }). The argument {} creates an optional unnamed variable for the interface name, and the argument {subinterface} creates an optional parameter named subinterface.

When you enter the alias at the CLI prompt, the output of the aliased command is displayed. For example:

display interface ethernet-1/1 subinterface 1
+---------------------+-------+-------------+
|      Interface      | Index | Admin-state |
+=====================+=======+=============+
| ethernet-1/1        |     1 | enable      |
+---------------------+-------+-------------+

If you omit the optional parameters for the interface and subinterface names, they are treated as wildcards. For example:

display interface
+---------------------+-------+-------------+
|      Interface      | Index | Admin-state |
+=====================+=======+=============+
| ethernet-1/1        |     1 | enable      |
| ethernet-1/2        |     1 | enable      |
| lo0                 |     1 | enable      |
| mgmt0               |     0 | enable      |
+---------------------+-------+-------------+

2.5.6. Configuring command auto-completion

By default, if you enter a tab at any mode or level to auto-complete the next command level, a popup appears that displays the available options for that command. See Using the CLI auto-complete function.

You can optionally configure the space bar to provide the same function as the Tab key, so that pressing the space bar auto-completes the command.

Example:

The following example configures the space bar to auto-complete commands in SR Linux CLI sessions:

--{ candidate shared default}--[  ]--
environment complete-on-space true

2.5.7. Displaying the CLI environment configuration

To display the CLI environment configuration, including any CLI command aliases, use the environment show command.

Example:

--{ candidate shared default}--[  ]--
environment show
[alias]
"show system configuration session" = "info from state / system configuration session {} | as table | filter fields username type started"
"show system configuration checkpoint" = "info from state / system configuration checkpoint {} | as table | filter fields name comment username created"
"display interface" = "info / interface {} subinterface {subinterface} | as table
 
[bottom-toolbar]
value = "Current mode: {modified}{mode_and_session_type} | {aaa_user} ({aaa_session_id})  {time}"
 
[cli-engine]
type = "advanced"
 
[output-display-format]
value = "text"
 
[prompt]
value = "--{{ {modified}{mode_and_session_type} }}--[ {pwc} ]--\n{host}# "
 
[space-completion]
enabled = false

2.5.8. Managing CLI environment settings

You can save the current CLI environment settings to the default SR Linux configuration or to a file, and you can load CLI environment settings from the default SR Linux configuration or from a file.

Examples:

The following example saves the current CLI environment settings to the default SR Linux configuration:

--{ candidate shared default}--[  ]--
environment save home
Saved configuration to /root/.srlinuxrc

The following example saves the current CLI environment settings to a file:

--{ candidate shared default}--[  ]--
environment save file env.cfg
Saved configuration to env.cfg

The following example loads CLI environment settings from the default SR Linux configuration:

--{ candidate shared default}--[  ]--
environment load home
Loaded configuration from /root/.srlinuxrc

The following example loads CLI environment settings from a file:

--{ candidate shared default}--[  ]--
environment load file env.cfg
Loaded configuration from env.cfg