User Interfaces · Topic 4 of 4
Managing, Comparing and Loading Configuration Files
Learn Junos set, delete, deactivate, save, show compare, file commands and load override, merge, replace and set for the JNCIA-Junos JN0-106 exam.
- 5 min
deactivatemarks a statementinactive:;activaterestores it;deleteremoves it.insertreorders terms in policies and firewall filters.savein configuration mode writes the candidate to your home directory.
What it is
Junos gives you a set of configuration mode commands to modify statements, and file commands to save, view, compare and load whole configurations. Together they let you copy a configuration between devices, keep a backup in a file, and check exactly what will change before you commit.
Everything you load or edit lands in the candidate configuration. Nothing becomes active until you commit.
How it works
Modifying statements
| Command | Effect |
|---|---|
set <statement> | Adds a statement or changes its value |
delete <statement> | Removes a statement and everything under it |
deactivate <statement> | Keeps the statement but marks it inactive: so it is ignored at commit |
activate <statement> | Removes the inactive mark |
copy <statement> to <new> | Copies a statement under a new name, for example one interface to another |
rename <statement> to <new> | Changes a statement's name |
insert | Moves an ordered item, such as a policy or filter term, before or after another |
annotate <statement> "<text>" | Adds a comment that appears above the statement |
replace pattern <old> with <new> | Replaces matching text throughout the candidate |
deactivate is handy for testing. The statement stays in the file, shown with an inactive: tag, and you can bring it back with activate instead of typing it again.
[edit]
user@R1# deactivate interfaces ge-0/0/2
[edit]
user@R1# show interfaces
ge-0/0/1 {
unit 0 {
family inet {
address 10.1.1.1/24;
}
}
}
inactive: ge-0/0/2 {
unit 0 {
family inet {
address 10.1.2.1/24;
}
}
}
Order matters in policies and firewall filters, because terms are evaluated top to bottom. New terms are added at the end, so insert is how you place a term earlier.
Viewing configurations
| Command | Mode | Shows |
|---|---|---|
show configuration | Operational | The active configuration |
show configuration interfaces | Operational | One part of the active configuration |
show | Configuration | The candidate at the current level |
The default format is the curly-brace hierarchy. Adding | display set, as in show | display set, turns it into flat set commands, which are easy to copy into another device.
Comparing configurations
Pick the comparison by what you want to check:
- Candidate against active:
show | comparein configuration mode. - Candidate against a saved version:
show | compare rollback <n>in configuration mode. - Active against a saved version:
show configuration | compare rollback <n>in operational mode. - Two saved versions:
show system rollback <n> compare <m>in operational mode. - Two files on the device:
file compare files <file1> <file2>in operational mode.
Output uses + for lines that would be added and - for lines that would be removed, grouped under [edit ...] headers that tell you where in the hierarchy the change is.
Saving and managing files
save <filename> in configuration mode writes the candidate to a file in your home directory. At the top level it saves the whole candidate, and at a lower level it saves only that part.
From operational mode, show configuration | save <filename> saves the active configuration. The file commands then manage what you saved.
| Command | Effect |
|---|---|
file list | Lists files in a directory |
file show <file> | Displays a file |
file copy <source> <destination> | Copies a file, locally or to a remote URL |
file rename <old> <new> | Renames a file |
file delete <file> | Deletes a file |
file copy can send a configuration to a server, for example with an ftp:// or scp:// destination, which is a simple manual backup.
Loading configurations
| Load option | Effect on the candidate |
|---|---|
load override <file> | Replaces the whole candidate with the file |
load merge <file> | Merges the file into the candidate; new statements are added, conflicting ones replaced |
load replace <file> | Replaces only the sections marked with a replace: tag in the file |
load set <file> | Loads a file of set commands |
load patch <file> | Applies a file of changes in the compare output format |
Use terminal instead of a file name to paste the text, then press Ctrl+D to finish. Add relative with load merge or load replace to load the text at your current hierarchy level instead of the top.
[edit]
user@R1# load merge terminal relative
[Type ^D at a new line to end input]
To copy a working configuration to a new device, save it with | display set, then use load set terminal on the new device, check it with show | compare, and commit.
Common mistakes
Confusing delete and deactivate. delete removes the statement. deactivate keeps it in the configuration but ignores it at commit.
Using load override for a small change. load override wipes the whole candidate, including the root password and management settings, and replaces it with the file. For an addition, use load merge.
Comparing the wrong configurations. show | compare in configuration mode compares the candidate with the active one. show configuration in operational mode has no candidate to compare, so it compares the active one with a rollback.
Expecting a loaded file to be active. Every load changes only the candidate. You still need to commit.
After load override, check with show | compare before you commit. A file from another device may change the host name, addresses and users all at once.
What to remember for the exam
deactivatemarks a statementinactive:;activaterestores it;deleteremoves it.insertreorders terms in policies and firewall filters.savein configuration mode writes the candidate to your home directory.show | compareshows candidate against active; addrollback nto compare with a saved version.load overridereplaces everything;load mergecombines;load replaceusesreplace:tags;load setreadssetcommands.terminallets you paste input, ending with Ctrl+D;relativeloads at the current level.
Check yourself
Which load option replaces the whole candidate configuration with a file?
load override.load mergewould combine the file with the existing candidate instead.What does deactivate do to a statement?
It keeps the statement but marks it
inactive:, so it is ignored when the configuration is committed.How do you see what will change before you commit?
Run
show | comparein configuration mode to compare the candidate with the active configuration.
Topic 4 of 4 in User Interfaces
Test yourself on User Interfaces
The full Juniper JNCIA-Junos JN0-106 question bank has 1,155 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.