Juniper Junos OS commands cheat sheet
Everyday Junos CLI commands grouped by task. Operational mode (prompt >) shows status; configuration mode (prompt #) edits a candidate configuration that does nothing until you commit it.
- Covers
- Junos OS 22.x and later (EX/SRX/MX; ELS syntax for EX switching)
- Commands
- 57
- Last verified
Editing and committing
| Command | What it does |
|---|---|
set <statement-path> | Add or change a statement in the candidate configuration. Example set system host-name SW1-OFFICEYour position in the hierarchy does not change. Nothing takes effect until commit. |
delete <statement-path> | Remove a statement and everything under it from the candidate configuration. Example delete protocols ospfWarning: All subordinate statements under the path are removed too. Live traffic is affected only after commit; rollback 0 undoes it before then. |
show | compare | Show uncommitted changes against the active configuration. Lines starting with + are added and lines starting with - are removed. Run it before every commit. |
show | compare rollback <n> | Compare the candidate with a previously committed configuration. Example show | compare rollback 1 |
commit check | Check the candidate configuration for errors without activating it. |
commit | Activate the candidate configuration. Add comment "<text>" to record why, for example commit comment "Add VLAN 30". View past commits with show system commit. |
commit confirmed <minutes> | Activate the candidate but roll back automatically unless you confirm in time. Example commit confirmed 5The default is 10 minutes. Confirm with commit or commit check before the timer ends. Use it for remote changes that could cut off your access. |
commit and-quit | Commit and return to operational mode in one step. |
rollback <n> | Load a previously committed configuration into the candidate. Example rollback 10 is the active configuration and 49 the oldest; Junos keeps the last 50 commits. Run commit to activate the one you loaded. |
rollback 0 | Discard all uncommitted changes in the candidate configuration. Reloads the active configuration into the candidate. Committed changes are not touched. |
Viewing the configuration
| Command | What it does |
|---|---|
show configuration | Show the committed configuration that is running now (operational mode). Example show configuration interfaces ge-0/0/1In configuration mode, show displays the candidate at the current level instead. |
show configuration | display set | Show the configuration as the set commands that would recreate it. In configuration mode use show | display set, or show | display set relative for paths from your current level. |
<command> | match <pattern> | Show only output lines that match a pattern. Example show configuration | display set | match ge-0/0/1Quote patterns that contain spaces. | except hides matching lines and | count counts lines. |
<command> | no-more | Print the whole output without pausing at each screen. Example show configuration | no-more |
System setup
| Command | What it does |
|---|---|
set system host-name <name> | Set the device hostname shown in the prompt. Example set system host-name SW1-OFFICEEnclose the name in double quotes if it contains spaces. |
set system root-authentication plain-text-password | Set the root password; you are prompted to type it twice. Junos will not accept a commit until a root password is set. The password is stored encrypted. |
set system login user <name> class super-user authentication plain-text-password | Create a local admin account with full permissions. Example set system login user netadmin class super-user authentication plain-text-passwordOther built-in classes are operator, read-only and unauthorized. |
set system services ssh | Enable the SSH server for remote management. |
set system ntp server <address> | Sync the system clock with an NTP server. Example set system ntp server 192.0.2.123Check sync with show ntp associations and show ntp status. |
set system name-server <address> | Add a DNS server for name resolution. Example set system name-server 192.0.2.53 |
Interfaces and VLANs (EX with ELS)
| Command | What it does |
|---|---|
set interfaces <interface> unit 0 family inet address <address/prefix> | Assign an IPv4 address to a routed interface. Example set interfaces ge-0/0/0 unit 0 family inet address 192.0.2.1/24 |
set interfaces <interface> disable | Administratively shut down an interface. Example set interfaces ge-0/0/5 disableBring it back with delete interfaces <interface> disable, then commit. |
set vlans <vlan-name> vlan-id <id> | Create a VLAN with a name and an 802.1Q ID. Example set vlans STAFF vlan-id 10On ELS switches every VLAN must have an ID or the commit fails. |
set interfaces <interface> unit 0 family ethernet-switching interface-mode access | Make a switch port an access port. Example set interfaces ge-0/0/1 unit 0 family ethernet-switching interface-mode access |
set interfaces <interface> unit 0 family ethernet-switching vlan members <vlan> | Put a port in a VLAN, by VLAN name or ID. Example set interfaces ge-0/0/1 unit 0 family ethernet-switching vlan members STAFFFor a trunk, list several VLANs in brackets, for example vlan members [ STAFF VOICE ]. |
set interfaces <interface> unit 0 family ethernet-switching interface-mode trunk | Make a switch port a trunk that carries several tagged VLANs. Example set interfaces ge-0/0/47 unit 0 family ethernet-switching interface-mode trunk |
set interfaces <interface> native-vlan-id <vlan-id> | Accept untagged data frames on a trunk and place them in this VLAN. Example set interfaces ge-0/0/47 native-vlan-id 99On ELS it goes on the physical interface, and the same VLAN must also be in the port's vlan members. Without it, untagged data frames on a trunk are dropped. |
set interfaces irb unit <n> family inet address <address/prefix> | Create a Layer 3 IRB interface to route for a VLAN. Example set interfaces irb unit 10 family inet address 192.168.10.1/24 |
set vlans <vlan-name> l3-interface irb.<n> | Bind the IRB interface to a VLAN so the VLAN can be routed. Example set vlans STAFF l3-interface irb.10 |
Routing
| Command | What it does |
|---|---|
set routing-options static route <prefix> next-hop <address> | Add a static route. Example set routing-options static route 198.51.100.0/24 next-hop 192.0.2.254Static routes have a default preference of 5 and become active only when the next hop is reachable. |
set routing-options static route 0.0.0.0/0 next-hop <address> | Add a default route. Example set routing-options static route 0.0.0.0/0 next-hop 203.0.113.1 |
show route | Show active entries in the routing tables. Example show route 198.51.100.0/24Add a prefix or address to see only matching routes. |
show route protocol <protocol> | Show only routes learned from one source, such as static, direct, local, ospf or bgp. Example show route protocol static |
Monitoring and troubleshooting
| Command | What it does |
|---|---|
show interfaces terse | List interfaces with admin and link state, protocol family and addresses. Example show interfaces terse | match ge-0/0 |
show vlans | List VLANs with their IDs and member interfaces (ELS). |
show ethernet-switching table | Show the MAC addresses the switch has learned, with VLAN and interface (ELS). |
show lldp neighbors | List neighboring devices discovered with LLDP. Example show lldp neighbors interface ge-0/0/47 |
show version | Show the hostname and the Junos OS version running on the device. |
show log messages | Show the main system log file. Example show log messages | last 50show log on its own lists the available log files. |
ping <host> count <n> | Send a set number of ICMP echo requests. Example ping 192.0.2.10 count 5Without count, ping runs until you press Ctrl+C. Add rapid for a single summary line, or source <address> to pick the source IP. |
traceroute <host> | Show the hops packets take to reach a destination. Example traceroute 198.51.100.25 |
monitor interface <interface> | Show live interface statistics, updated every second. Example monitor interface ge-0/0/1Use monitor interface traffic for all active interfaces. Press q or Esc to quit. |
monitor traffic interface <interface> | Capture packet headers sent and received by the Routing Engine on an interface. Example monitor traffic interface ge-0/0/0 no-resolve count 20Shows control-plane traffic to and from the device, not transit traffic. Use count to stop after a number of packets. |
Files, rescue and system
| Command | What it does |
|---|---|
save <filename> | Save the candidate configuration at the current level to a file (configuration mode). Example save sw1-backup.confBy default the file goes in your home directory. It includes uncommitted changes. |
file list <path> | List files on the device. Example file list /var/tmp detail |
load merge terminal | Paste configuration text and merge it into the candidate. Press Ctrl+D on a new line to finish. Use load set terminal to paste set commands. Review with show | compare, then commit. |
load override <filename> | Replace the whole candidate configuration with a saved file. Example load override sw1-backup.confWarning: Everything in the candidate that is not in the file is discarded, and the next commit makes that live. Check with show | compare before committing. |
request system configuration rescue save | Save the current committed configuration as the rescue configuration. Restore it later with rollback rescue followed by commit. |
request system reboot | Reboot the device. Example request system reboot in 10Warning: All traffic through the device stops while it restarts. Commit or discard pending changes first. EX switches wait one minute before rebooting; clear system reboot cancels a scheduled reboot. |
request system zeroize | Erase all configuration, logs and user files and reset the device to factory defaults. Warning: Removes the configuration, log files, passwords, secrets and private keys, then reboots to the factory default configuration. Afterwards you can only log in from the console as root. Back up the configuration first. |
Official references
Last verified against these pages. Commands marked Warning restart, erase or remove something: run them only in a maintenance window and with a backup.
- Junos OS CLI User Guide: Commit the Configuration juniper.net
- Junos OS CLI User Guide: CLI Configuration Mode Overview juniper.net
- Junos OS CLI User Guide: Overview of the Configure Command juniper.net
- Junos OS CLI User Guide: View the Configuration juniper.net
- Junos OS: Layer 2 Networking (Enhanced Layer 2 Software) juniper.net
- Junos OS: Configure Static Routes juniper.net
- Junos OS CLI Reference: request system reboot juniper.net
- Junos OS CLI Reference: request system zeroize juniper.net
Questions people ask
What is the difference between operational mode and configuration mode in Junos?
Operational mode (prompt >) is for monitoring and troubleshooting with commands such as show, ping and monitor. Configuration mode (prompt # with an [edit] banner), entered with configure, is for changing settings. Changes made there go into a candidate configuration and only take effect when you run commit.
How does commit confirmed work in Junos?
commit confirmed activates the candidate configuration temporarily. If you do not enter commit or commit check within the timeout (10 minutes by default, or the number of minutes you give, such as commit confirmed 5), Junos automatically rolls back to the previous configuration. It protects you from losing remote access through a bad change.
How do I undo a configuration change on a Juniper device?
For uncommitted changes, run rollback 0 in configuration mode to discard them. To return to an earlier committed configuration, run rollback <n> (for example rollback 1 for the previous one), check it with show | compare, then commit. Junos keeps the last 50 committed configurations, numbered 0 to 49.
How do I show the Junos configuration as set commands?
In operational mode run show configuration | display set. In configuration mode run show | display set, or show | display set relative to see paths from your current hierarchy level. Add | match <pattern> to filter, for example show configuration | display set | match ge-0/0/1.